Start Debugging

EF Core 11 cheat sheet

The parts of EF Core 11 worth remembering.

This pillar is a running index of everything I’ve written about EF Core 11 - new query features, vector search, performance work, and migration notes from EF Core 8, 9, or 10.

What to read first

For the headline 11.0 features, start with SQL Server vector search over DiskANN indexes and Cosmos DB transactional batches on by default; on Cosmos, the generated id escaping change needs a migration before you upgrade. Before you model, TPH vs TPT vs TPC and complex types vs owned entities settle the schema shape, and optimistic concurrency with a rowversion token stops concurrent writes clobbering each other - the failure it prevents is a 23505 duplicate-key violation.

For query work, pruned reference joins in split queries and Contains translating to JSON_CONTAINS are the changes you’ll feel in generated SQL, and native json vs nvarchar(max) decides whether you get them. Watch EF.Functions.Like, which doesn’t escape % and _ the way StartsWith does. EF.Parameter vs EF.Constant decides what gets inlined, and Contains on a static readonly IList is a translation failure 11 fixes. To hook SaveChanges without wrapping the context, what an interceptor is covers the seven interception points. For hot paths, detecting N+1 queries and compiled queries are the follow-ups, and ExecuteUpdate and ExecuteDelete for bulk writes is the set-based path. Upgrading? Migrate EF Core 6 to EF Core 11 is the checklist.

What’s on this page

The list below auto-collects posts tagged with any of: ef-core, ef-core-11, efcore, efcore-11, entity-framework. Newest first.

Index (100 posts)

2026 / 10

  • How to set PostgreSQL session parameters such as search_path or statement_timeout on every EF Core connection with Npgsql

    A SET statement run once is wiped by DISCARD ALL the moment Npgsql returns the connection to its pool. Put search_path and statement_timeout in the startup packet with the Search Path and Options connection string keywords, fall back to ALTER ROLE or a ConnectionOpened interceptor, and know why UsePhysicalConnectionInitializer silently loses its SET.

  • EF.Parameter vs EF.Constant in EF Core 11 queries

    EF.Constant inlines a captured value as a SQL literal, EF.Parameter turns a literal into a SQL parameter. Keep EF Core's defaults, use EF.Parameter to stop dynamically built expression trees from recompiling on every call, and use EF.Constant only for a value with a handful of distinct values whose data is skewed enough to need its own plan.

2026 / 09

2026 / 08

2026 / 07

2026 / 06

2026 / 05

2026 / 04

  • How to warm up EF Core's model before the first query

    EF Core builds its conceptual model lazily on the first DbContext access, which is why the first query in a fresh process is several hundred milliseconds slower than every query after it. This guide covers the three real fixes in EF Core 11: a startup IHostedService that touches Model and opens a connection, dotnet ef dbcontext optimize to ship a precompiled model, and the cache-key footguns that silently rebuild the model anyway.

  • How to mock DbContext without breaking change tracking

    Mocking DbContext directly silently breaks ChangeTracker, which is why Microsoft discourages it. This guide shows the two patterns that actually work in EF Core 11: SQLite in-memory with a kept-open connection so the real ChangeTracker runs, and the repository pattern that lifts EF Core out of the test entirely.

  • EF Core 11 Preview 3 Adds RemoveDbContext for Clean Test Provider Swaps

    EF Core 11 Preview 3 introduces RemoveDbContext, RemoveExtension, and a parameterless AddPooledDbContextFactory overload, removing the boilerplate around swapping providers in tests and centralizing pooled factory configuration.

  • How to use IAsyncEnumerable<T> with EF Core 11

    EF Core 11 queries implement IAsyncEnumerable<T> directly. Here is how to stream rows with await foreach, when to prefer it over ToListAsync, and the gotchas around connections, tracking, and cancellation.

  • How to use records with EF Core 11 correctly

    A practical guide to mixing C# records and EF Core 11. Where records fit, where they break change tracking, and how to model value objects, entities, and projections without fighting the framework.

  • EF Core 11 translates Contains to JSON_CONTAINS on SQL Server 2025

    EF Core 11 auto-translates LINQ Contains over JSON collections to the new SQL Server 2025 JSON_CONTAINS function, and adds EF.Functions.JsonContains for path-scoped and mode-specific queries that can hit a JSON index.

  • EF Core 11 Prunes Unnecessary Reference Joins in Split Queries

    EF Core 11 Preview 3 removes redundant to-one joins from split queries and drops unneeded ORDER BY keys. One reported scenario got 29% faster, another 22%. Here is what the SQL now looks like.

  • EF Core 11 Adds GetEntriesForState to Skip DetectChanges

    EF Core 11 Preview 3 introduces ChangeTracker.GetEntriesForState, a state-filtered enumerator that avoids an extra DetectChanges pass in hot paths like SaveChanges interceptors and audit hooks.

  • EF Core 11 turns on Cosmos DB transactional batches by default

    EF Core 11 groups Cosmos DB writes into transactional batches per container and partition on every SaveChanges, giving best-effort atomicity and fewer roundtrips without any code changes.

  • EF Core 11 Lets You Create and Apply a Migration in One Command

    The dotnet ef database update command now accepts --add to scaffold and apply a migration in a single step. Here is how it works, why it matters for containers and .NET Aspire, and what to watch for.

  • EF Core 11 Adds Native SQL Server Vector Search with DiskANN Indexes

    EF Core 11 Preview 2 supports SQL Server 2025 VECTOR_SEARCH() and DiskANN vector indexes directly from LINQ. Here is how to set up the index, run approximate queries, and what changes from the EF Core 10 VectorDistance approach.

2023 / 06

All pillars Home