← Back to blog

EF Core 10 + SQL Server: Native JSON Support Has Officially Arrived

  • EF Core
  • SQL Server
  • C#
  • .NET
  • JSON

EF Core 10 now lets you store and query JSON data directly in SQL Server, just like in PostgreSQL. You can keep complex, flexible documents in a column while still using strong typing and full LINQ queries. This blends NoSQL-style flexibility with SQL Server’s reliable relational engine, simplifying development for modern apps.

Now, it lets you store flexible data (like settings or configurations) in a JSON column without the mess. Your C# objects are saved as JSON, but you can still query and update them like normal database rows. It’s the best of both worlds: simple storage and powerful code.

Consider a simple Item table with the columns { Id, Name, Configuration, ConfigurationDate }. Instead of splitting Configuration across multiple relational tables, we model it as a structured object in C# and persist it directly as a JSON document in SQL Server.

The Item entity contains a strongly typed ItemConfiguration object that represents properties like colour, warranty years, and return eligibility. EF Core treats this object as a first-class citizen rather than a serialised blob.

Entity Model: This approach keeps the domain model clean, expressive, and fully type-safe, while still taking advantage of flexible JSON storage at the database level.

public class Item
{
    public int Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public ItemConfiguration Configuration { get; set; } = new();
    public DateTime ConfigurationDate { get; set; }
}

public class ItemConfiguration
{
    public string Color { get; set; } = string.Empty;
    public int WarrantyYears { get; set; }
    public bool IsReturnable { get; set; }
}

Setting JSON column type: With this configuration, EF Core 10 understands that the Configuration property maps to a native JSON column in SQL Server. No value converters, no manual serialisation, and no workaround libraries are required.

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Item>(builder =>
    {
        builder.ToTable("Items");

        builder.Property(x => x.Configuration)
            .HasColumnType("json")
            .IsRequired();
    });
}

Saving JSON Data Is Fully Transparent: Behind the scenes, EF Core stores this configuration as structured JSON inside SQL Server, while your application continues working with strongly typed objects.

var item = new Item
{
    Name = "Laptop",
    ConfigurationDate = DateTime.UtcNow,
    Configuration = new ItemConfiguration
    {
        Color = "Silver",
        WarrantyYears = 2,
        IsReturnable = true
    }
};

dbContext.Items.Add(item);
await dbContext.SaveChangesAsync();

LINQ-to-JSON Querying Is the Real Breakthrough: This LINQ query translates directly into an optimised SQL Server JSON query. The developer experience remains pure C#, while the database executes efficient native JSON filtering without any client-side evaluation.

var returnableItems = await dbContext.Items
    .Where(x => x.Configuration.IsReturnable == true)
    .ToListAsync();

It finally brings true JSON flexibility to SQL Server. You get NoSQL-like agility for dynamic data without losing SQL’s power for everything else. This eliminates a major design compromise, letting you build more adaptable and simpler systems in one familiar platform.

Thanks!

Contact