Entity Framework Core 7 Preview: JSON Columns

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.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.