Swevo.EFCore.JsonColumn
1.0.1
Prefix Reserved
dotnet add package Swevo.EFCore.JsonColumn --version 1.0.1
NuGet\Install-Package Swevo.EFCore.JsonColumn -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Swevo.EFCore.JsonColumn" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Swevo.EFCore.JsonColumn" Version="1.0.1" />
<PackageReference Include="Swevo.EFCore.JsonColumn" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Swevo.EFCore.JsonColumn --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Swevo.EFCore.JsonColumn, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Swevo.EFCore.JsonColumn@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Swevo.EFCore.JsonColumn&version=1.0.1
#tool nuget:?package=Swevo.EFCore.JsonColumn&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Swevo.EFCore.JsonColumn
Compile-time JSON column configuration for EF Core 8+. Stamp [JsonColumn] on owned navigation properties and the source generator emits ConfigureJsonColumns(ModelBuilder) so you do not have to hand-write repetitive OwnsOne(..., b => b.ToJson()) boilerplate.
Quick-start
dotnet add package Swevo.EFCore.JsonColumn
1 — Mark JSON-owned navigations
using EFCore.JsonColumn;
public class Address
{
public string Street { get; set; } = "";
public string City { get; set; } = "";
}
public class Order
{
public int Id { get; set; }
[JsonColumn]
public Address ShippingAddress { get; set; } = new();
}
2 — Configure your DbContext
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
=> modelBuilder.ConfigureJsonColumns();
}
3 — Generated output
modelBuilder.Entity<global::MyApp.Order>(entity =>
{
entity.OwnsOne(e => e.ShippingAddress, b => b.ToJson());
});
How it works
[JsonColumn]marks an owned reference navigation for JSON-column configuration- The incremental source generator scans the full compilation for annotated properties
- One generated
ConfigureJsonColumns(ModelBuilder)method groups properties by owning entity - Each property becomes
entity.OwnsOne(e => e.PropertyName, b => b.ToJson())
Requirements
- .NET 8+
- EF Core 8+
- JSON-column properties must be reference types
Applying [JsonColumn] to a value type produces warning JSCOL001.
License
MIT
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.