.NET 11 Preview 3 includes new EF Core features and tooling improvements:
ChangeTracker.GetEntriesForState()avoids extra change detection- DbContext configuration can remove providers and add pooled factories
- Migrations get more control and clearer feedback
- SQL generation removes unnecessary joins and SQL Server adds JSON APIs
- Breaking changes
- Bug fixes
- Community contributors
EF Core updates in .NET 11:
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);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>();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);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).
RelationalEventId.MigrationsNotFoundnow throws by default instead of only logging an informational message (dotnet/efcore #37839).Microsoft.EntityFrameworkCore.ToolsandMicrosoft.EntityFrameworkCore.Tasksno longer depend directly onMicrosoft.EntityFrameworkCore.Design(dotnet/efcore #37837).- The
EFOptimizeContextMSBuild property has been removed. If you set it in your project or build pipeline, remove it and use theEFScaffoldModelStageandEFPrecompileQueriesStageproperties instead (dotnet/efcore #37838). SqlVectorproperties 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.SqlClientto 7.0.0. Review the SqlClient release notes if you depend on provider-specific SQL Server behavior (dotnet/efcore #37949).
- Improved error reporting when spatial or
HierarchyIdtypes are used without the expected provider configuration (dotnet/efcore #37733). - Added a clearer exception when a property's backing field cannot be found (dotnet/efcore #36720).
- Fixed
ExecuteUpdateover scalar projections and nullable-value-typeSetPropertylambdas (dotnet/efcore #37791, dotnet/efcore #37975). - Fixed several JSON and complex-property edge cases in query translation and migrations (dotnet/efcore #37823, dotnet/efcore #37855, dotnet/efcore #37965).
Thank you to the community contributors who made EF Core better in this preview:
- @aw0lid (Ahmed Waleed): Fixed a memory leak in
LazyLoaderFactorywhere strong references toILazyLoaderinstances prevented garbage collection during large-scale data streaming (dotnet/efcore #37977) - @bkarakaya01 (Burak Karakaya): Added
parameterless
AddPooledDbContextFactoryoverloads for cleaner DI registration withConfigureDbContext(dotnet/efcore #37144) - @JoasE: Implemented Cosmos DB complex-properties query support and follow-up fixes (dotnet/efcore #37577, dotnet/efcore #37919, dotnet/efcore #37941, dotnet/efcore #37971)
- @kawasaniac (Arkadii): Added descriptive exceptions when a property's backing field cannot be found during compiled model code generation (dotnet/efcore #36720)
- @MarkMpn (Mark Carrington): Enabled foreign key support in Dataverse reverse engineering (dotnet/efcore #34689)
- @Pmyl (Giulio Caprino): Fixed persisting null optional complex properties with default values (dotnet/efcore #37944)
- @SimonCropp (Simon Cropp): Updated
Microsoft.Data.SqlClientto 7.0.0 (dotnet/efcore #37949) - @yykkibbb: Improved error reporting for spatial
and
HierarchyIdtypes without provider configured and ensuredHasPrecisionis always scaffolded fordecimalcolumns in SQL Server (dotnet/efcore #37733, dotnet/efcore #37730)