EF Core 7 introduces mapping JSON columns to complex types.
public class Order
{
public int Id { get; set; }
public Address ShippingAddress { get; set; } // Stored as JSON
}
modelBuilder.Entity<Order>()
.OwnsOne(o => o.ShippingAddress, a => a.ToJson());
The Address object is serialized to a JSON column in SQL Server/PostgreSQL. You can query inside it with LINQ!
Discover more from C4: Container, Code, Cloud & Context
Subscribe to get the latest posts sent to your email.