Home › Blog › Entity Framework Interview Questions (2026): 30 EF Core Questions on Tracking and Loading

Entity Framework Interview Questions (2026): 30 EF Core Questions on Tracking and Loading

Entity Framework interview questions today mean EF Core: how a DbContext tracks entities, how LINQ becomes SQL, how you load related data without N+1 queries, and how you manage migrations, concurrency and performance. Per Microsoft Learn, EF Core 10 shipped in November 2025 as a long-term-support release supported until November 10, 2028, and NuGet listed EF Core 11.0.0 alongside .NET 11 when we checked on November 17, 2026.

Entity Framework interview questions today mean EF Core: how a DbContext tracks entities, how LINQ becomes SQL, how you load related data without N+1 queries, and how you manage migrations, concurrency and performance. Per Microsoft Learn, EF Core 10 shipped in November 2025 as a long-term-support release supported until November 10, 2028, and NuGet listed EF Core 11.0.0 alongside .NET 11 when we checked on November 17, 2026.

Below are 30 questions by level, five scenarios and how interviews test this. The web layer above EF is in ASP.NET Core interview questions, and the database most EF shops run is covered in SQL Server interview questions.

Entity Framework interview questions: fundamentals (1–10)

  1. What is EF Core? Microsoft's object-relational mapper for modern .NET. A DbContext exposes DbSet<T> properties, and a provider (SQL Server, PostgreSQL, SQLite, Cosmos DB and others) translates LINQ into queries. EF6 is the older .NET Framework product.
  2. What lifetime should a DbContext have? Short: one unit of work. It is not thread-safe, so never share it across concurrent operations. AddDbContext registers it as scoped, one per request; AddDbContextPool reuses instances to cut allocation cost.
  3. Code-first or database-first? Code-first defines the model in C# and evolves the schema with migrations. Database-first scaffolds the model from an existing schema with dotnet ef dbcontext scaffold.
  4. How do migrations work? dotnet ef migrations add AddOrders generates Up and Down methods and updates the model snapshot; dotnet ef database update applies them. In production, prefer an idempotent script (dotnet ef migrations script --idempotent) or a migration bundle run by the pipeline.
  5. What are entity states? Detached, Added, Unchanged, Modified and Deleted. SaveChanges detects changes against snapshots and issues the INSERT, UPDATE and DELETE statements.
  6. When do you use AsNoTracking? For read-only queries: no snapshots, less memory, faster. Results are not identity-resolved; AsNoTrackingWithIdentityResolution gives identity resolution without tracking.
  7. IQueryable or IEnumerable? IQueryable builds an expression the provider turns into SQL. Calling ToList() or AsEnumerable() too early pulls every row into memory and filters there.
  8. What are the ways to load related data? Eager with Include and ThenInclude; explicit with context.Entry(blog).Collection(b => b.Posts).LoadAsync(); lazy with the proxies package (UseLazyLoadingProxies and virtual navigations), which triggers a query on first access.
  9. Is SaveChanges transactional? Yes. By default all changes in one SaveChanges run in a single transaction. Use BeginTransactionAsync to span several SaveChanges calls or raw SQL.
  10. Data annotations or Fluent API? Annotations for simple rules ([Required], [MaxLength]); the Fluent API in OnModelCreating for composite keys, relationships, indexes and conversions, organized with IEntityTypeConfiguration<T>.

Intermediate Entity Framework questions (11–20)

  1. How does N+1 happen in EF Core? Lazy loading inside a loop: one query for the list, one per item for its navigation. Fix with Include or, better for APIs, a Select projection that fetches exactly what is returned.
  2. What is cartesian explosion and how do split queries help? Including several collections in one JOIN multiplies rows. AsSplitQuery() runs one query per collection instead; the trade-off is more round trips and no single consistent snapshot without a transaction.
  3. Why project to DTOs? Select(o => new OrderDto(o.Id, o.Total)) reads only the needed columns, skips tracking and avoids accidental lazy loads.
  4. How does optimistic concurrency work? Mark a concurrency token, such as a SQL Server rowversion with [Timestamp] or a property with [ConcurrencyCheck]. Updates include it in the WHERE clause; zero rows affected throws DbUpdateConcurrencyException, and you reload, overwrite or merge.
  5. How do you run raw SQL safely? FromSql($"SELECT * FROM Blogs WHERE Id = {id}") turns interpolated values into parameters; FromSqlRaw needs explicit parameters. SqlQuery<T> returns types outside the model. EF Core 10 warns when you concatenate strings into raw SQL APIs.
  6. What are ExecuteUpdate and ExecuteDelete? Set-based operations, added in EF Core 7, that run without loading entities: await db.Products.Where(p => p.Discontinued).ExecuteDeleteAsync();. They bypass the change tracker. EF Core 10 lets ExecuteUpdateAsync take a regular lambda, so setters can be built conditionally.
  7. What are global query filters? HasQueryFilter adds a predicate to every query for an entity, which suits soft delete and multi-tenancy. EF Core 10 added named filters, so one query can disable just one: IgnoreQueryFilters(["SoftDeletionFilter"]).
  8. Owned types or complex types? Owned types (OwnsOne) are entity types with hidden keys. Complex types, added in EF Core 8, have value semantics and no identity; EF Core 10 extended them to table splitting and JSON mapping.
  9. What are value converters? Mappings between a property type and a column type, such as storing an enum as text with .HasConversion<string>(), or a strongly typed ID as its underlying value.
  10. What are shadow properties? Properties in the model but not on the class, such as a LastUpdated audit column, read with EF.Property<DateTime>(e, "LastUpdated").

Experienced and senior Entity Framework questions (21–30)

  1. What is on your EF Core performance checklist? AsNoTracking or projections for reads, pagination, proper indexes (HasIndex), no client-side filtering, compiled queries for hot paths (EF.CompileAsyncQuery), context pooling, and checking the SQL with LogTo or ToQueryString().
  2. What happened to client evaluation? Since EF Core 3.0, a query part that cannot be translated to SQL throws instead of silently running in memory, except in the final projection. Rewrite it, or switch to in-memory work deliberately with AsEnumerable().
  3. How do you insert a million rows? AddRange with SaveChanges batches statements but tracks everything. For very large loads, insert in chunks with a fresh context per chunk, or use the provider's bulk copy, such as SqlBulkCopy for SQL Server.
  4. What are interceptors used for? Hooking into EF operations: SaveChangesInterceptor for audit fields or soft delete, DbCommandInterceptor for logging or query hints.
  5. How do teams manage migrations? One migration per change, review the generated SQL, never edit a migration already applied elsewhere, resolve model snapshot conflicts after merges, and use expand-and-contract for breaking schema changes.
  6. How do you test EF Core code? Against a real database where behaviour matters, for example a containerized SQL Server or PostgreSQL. Microsoft's docs advise against the in-memory provider for testing because it does not behave like a relational database; SQLite in-memory is a middle ground.
  7. How do retries interact with transactions? With EnableRetryOnFailure, wrap a user-initiated transaction in db.Database.CreateExecutionStrategy().ExecuteAsync(...) so the whole unit retries together.
  8. How does EF map JSON columns? Map owned or complex types to a JSON column with ToJson() and query inside them with LINQ. EF Core 10 uses SQL Server 2025's native json type when the compatibility level is 170 or higher.
  9. What vector search support exists? EF Core 10 added vector search support for Azure SQL and SQL Server; EF Core 11's what's-new page lists VECTOR_SEARCH() and vector indexes for SQL Server.
  10. EF Core or Dapper? EF Core for productivity: change tracking, migrations, LINQ. Dapper for hand-written SQL with minimal overhead. Many teams use EF for writes and most reads, and raw SQL or Dapper for a few hot, complex queries.

Entity Framework scenario and troubleshooting questions

An orders endpoint got slow as data grew. Log the SQL. Usually N+1 from lazy loading or a cartesian explosion from several Includes. Project to a DTO, or Include with AsSplitQuery(), and paginate.

A long-running import keeps using more memory. The change tracker holds every entity. Use a new context per batch or call ChangeTracker.Clear() after each SaveChanges, and AsNoTracking for lookups.

"A second operation was started on this context instance". The same DbContext is used concurrently, often from Task.WhenAll or a missing await. Await each call, or give each parallel operation its own context through IDbContextFactory<T>.

Users overwrite each other's edits. Add a concurrency token, catch DbUpdateConcurrencyException, and decide the policy: reload and show the conflict, client wins, or merge field by field.

A migration breaks production during deploy. Run reviewed, idempotent scripts or bundles from the pipeline rather than at startup on every instance, and split breaking changes such as column renames into expand, migrate data, then contract.

How Entity Framework interviews test this

FormatWhat it usually looks likeHow to prepare
Concept Q&ADbContext lifetime, tracking, loading strategies, migrations, concurrencyExplain each with a one-line LINQ example
LINQ exerciseWrite a query and say what SQL it produces, or why it is slowPractice with ToQueryString() on your own model
Code reviewSpot N+1, early ToList, shared DbContext or a missing awaitRead data-access code with those four in mind
Senior designData access layer, migration strategy, multi-tenancy, read modelsBring one performance fix with before and after timings

Language-level follow-ups (async, LINQ, generics) are in C# interview questions, and runtime ones in .NET interview questions.

Where CoPilot Interview fits

CoPilot Interview is an AI interview assistant. Its free AI mock interview builds Entity Framework and .NET questions from your résumé and the job description, reads them aloud and scores each spoken answer out of 10, which is a fast way to find the answers above that you know but cannot yet explain cleanly under pressure. The browser demo has 145 practice questions in 10 tracks, scores typed answers out of 10 and needs no signup. The free plan gives 15 minutes a day of live help in sessions of up to 15 minutes, with AI mock interviews included. Paid plans are Standard at $24.99 a month and Pro at $39.99 a month, in the desktop app for Windows 10/11 and macOS 12 or later.

Use it to practice. Online assessments, proctored tests, take-home tasks with rules and AI-led rounds forbid outside help, so prepare for those instead of bringing a tool. For any live interview, follow your employer's rules.

Disclosure: CoPilot Interview is our product, so weigh what we say about it accordingly.

Frequently asked questions

What are the most common Entity Framework interview questions?

DbContext lifetime, change tracking and AsNoTracking, eager versus lazy versus explicit loading, the N+1 problem, migrations, optimistic concurrency, raw SQL safety and ExecuteUpdate or ExecuteDelete.

What is the difference between EF and EF Core?

EF6 is the older framework for .NET Framework; EF Core is the cross-platform rewrite for modern .NET, with different APIs, better performance and active development.

When should I use AsNoTracking?

Whenever you read data you will not update in the same context, such as API responses and reports. It saves memory and time.

What is the latest EF Core version?

EF Core 11.0.0 was on NuGet alongside .NET 11 as of November 17, 2026; EF Core 10 is the long-term-support release, supported until November 10, 2028.

Is EF Core slower than Dapper?

It adds overhead for tracking and translation, but with no-tracking queries and projections the gap is small for most workloads. Use raw SQL or Dapper for the few queries where it matters.

Practice this interview before the real one

The AI mock interview builds questions from your resume and the job description, reads them aloud and scores each spoken answer out of 10. Included on the free plan.

Start a mock interview