Skip to content

Latest commit

 

History

History
155 lines (130 loc) · 8.03 KB

File metadata and controls

155 lines (130 loc) · 8.03 KB

EF Core in .NET 11 Preview 3 - Release Notes

.NET 11 Preview 3 includes new EF Core features and tooling improvements:

EF Core updates in .NET 11:

ChangeTracker.GetEntriesForState() avoids extra change detection

A new GetEntriesForState() API on ChangeTracker returns tracked entities in selected states without forcing a DetectChanges() pass first (dotnet/efcore #37847). This avoids an extra DetectChanges() pass in long-lived contexts or high-volume change-tracking code where you already know which states you care about.

var modified = context.ChangeTracker.GetEntriesForState(
    added: false,
    modified: true,
    deleted: false,
    unchanged: false);

DbContext configuration can remove providers and add pooled factories

Preview 3 adds RemoveDbContext() / RemoveExtension() helpers for removing a previous provider configuration before registering a different one (dotnet/efcore #37891). This is especially useful in tests, where a production SQL Server configuration is replaced with an in-memory or SQLite provider.

AddPooledDbContextFactory<TContext>() also now has a parameterless overload, so configuration that already lives in ConfigureDbContext<TContext>() no longer needs the extra setup boilerplate (dotnet/efcore #37144).

services.RemoveDbContext<MyContext>();
services.AddPooledDbContextFactory<MyContext>();

Migrations get more control and clearer feedback

EF Core now lets you exclude a foreign-key constraint from migrations with ExcludeForeignKeyFromMigrations(true) (dotnet/efcore #37815). The model snapshot also records the latest migration ID so EF can detect diverged migration trees earlier in team workflows (dotnet/efcore #37689).

modelBuilder.Entity<Order>()
    .HasOne(o => o.Customer)
    .WithMany(c => c.Orders)
    .ExcludeForeignKeyFromMigrations(true);

SQL generation removes unnecessary joins and SQL Server adds JSON APIs

Query generation for to-one joins now removes unnecessary joins in common cases (dotnet/efcore #37819). SQL Server 2025 now supports EF.Functions.JsonContains(), and the earlier preview API has been renamed to JsonPathExists() for clarity (dotnet/efcore #37714, dotnet/efcore #37732).

Breaking changes

  • RelationalEventId.MigrationsNotFound now throws by default instead of only logging an informational message (dotnet/efcore #37839).
  • Microsoft.EntityFrameworkCore.Tools and Microsoft.EntityFrameworkCore.Tasks no longer depend directly on Microsoft.EntityFrameworkCore.Design (dotnet/efcore #37837).
  • The EFOptimizeContext MSBuild property has been removed. If you set it in your project or build pipeline, remove it and use the EFScaffoldModelStage and EFPrecompileQueriesStage properties instead (dotnet/efcore #37838).
  • SqlVector properties are no longer loaded by default. Explicitly project or load vector values if your application needs them (dotnet/efcore #37829).
  • Preview 3 updates Microsoft.Data.SqlClient to 7.0.0. Review the SqlClient release notes if you depend on provider-specific SQL Server behavior (dotnet/efcore #37949).

Bug fixes

Community contributors

Thank you to the community contributors who made EF Core better in this preview: