[](https://www.nuget.org/packages/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.
dotnet add package Swevo.EFCore.JsonColumnusing 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();
}public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
=> modelBuilder.ConfigureJsonColumns();
}modelBuilder.Entity<global::MyApp.Order>(entity =>
{
entity.OwnsOne(e => e.ShippingAddress, b => b.ToJson());
});[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())
- .NET 8+
- EF Core 8+
- JSON-column properties must be reference types
Applying [JsonColumn] to a value type produces warning JSCOL001.
🌐 Full suite overview: swevo.github.io
| Package | Description |
|---|---|
| AutoLog.Generator | Compile-time high-performance logging — [Log(Level, Message)] generates LoggerMessage.Define. AOT-safe. |
| AutoHttpClient.Generator | Compile-time typed HTTP client — [HttpClient] on an interface generates a strongly-typed client. AOT-safe Refit alternative. |
| AutoDispatch.Generator | Compile-time CQRS dispatcher — [Handler] generates a strongly-typed IDispatcher. No MediatR, no reflection. |
| AutoWire | Compile-time DI auto-registration — [Scoped]/[Singleton]/[Transient] generates IServiceCollection registration code. |
| AutoMap.Generator | Compile-time object mapping with generated extension methods. AOT-safe AutoMapper alternative. |
MIT