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)
- What is EF Core? Microsoft's object-relational mapper for modern .NET. A
DbContextexposesDbSet<T>properties, and a provider (SQL Server, PostgreSQL, SQLite, Cosmos DB and others) translates LINQ into queries. EF6 is the older .NET Framework product. - What lifetime should a DbContext have? Short: one unit of work. It is not thread-safe, so never share it across concurrent operations.
AddDbContextregisters it as scoped, one per request;AddDbContextPoolreuses instances to cut allocation cost. - 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. - How do migrations work?
dotnet ef migrations add AddOrdersgeneratesUpandDownmethods and updates the model snapshot;dotnet ef database updateapplies them. In production, prefer an idempotent script (dotnet ef migrations script --idempotent) or a migration bundle run by the pipeline. - What are entity states?
Detached,Added,Unchanged,ModifiedandDeleted.SaveChangesdetects changes against snapshots and issues the INSERT, UPDATE and DELETE statements. - When do you use AsNoTracking? For read-only queries: no snapshots, less memory, faster. Results are not identity-resolved;
AsNoTrackingWithIdentityResolutiongives identity resolution without tracking. - IQueryable or IEnumerable?
IQueryablebuilds an expression the provider turns into SQL. CallingToList()orAsEnumerable()too early pulls every row into memory and filters there. - What are the ways to load related data? Eager with
IncludeandThenInclude; explicit withcontext.Entry(blog).Collection(b => b.Posts).LoadAsync(); lazy with the proxies package (UseLazyLoadingProxiesand virtual navigations), which triggers a query on first access. - Is SaveChanges transactional? Yes. By default all changes in one
SaveChangesrun in a single transaction. UseBeginTransactionAsyncto span severalSaveChangescalls or raw SQL. - Data annotations or Fluent API? Annotations for simple rules (
[Required],[MaxLength]); the Fluent API inOnModelCreatingfor composite keys, relationships, indexes and conversions, organized withIEntityTypeConfiguration<T>.
Intermediate Entity Framework questions (11–20)
- 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
Includeor, better for APIs, aSelectprojection that fetches exactly what is returned. - 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. - Why project to DTOs?
Select(o => new OrderDto(o.Id, o.Total))reads only the needed columns, skips tracking and avoids accidental lazy loads. - How does optimistic concurrency work? Mark a concurrency token, such as a SQL Server
rowversionwith[Timestamp]or a property with[ConcurrencyCheck]. Updates include it in the WHERE clause; zero rows affected throwsDbUpdateConcurrencyException, and you reload, overwrite or merge. - How do you run raw SQL safely?
FromSql($"SELECT * FROM Blogs WHERE Id = {id}")turns interpolated values into parameters;FromSqlRawneeds explicit parameters.SqlQuery<T>returns types outside the model. EF Core 10 warns when you concatenate strings into raw SQL APIs. - 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 letsExecuteUpdateAsynctake a regular lambda, so setters can be built conditionally. - What are global query filters?
HasQueryFilteradds 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"]). - 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. - 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. - What are shadow properties? Properties in the model but not on the class, such as a
LastUpdatedaudit column, read withEF.Property<DateTime>(e, "LastUpdated").
Experienced and senior Entity Framework questions (21–30)
- 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 withLogToorToQueryString(). - 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(). - How do you insert a million rows?
AddRangewithSaveChangesbatches 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 asSqlBulkCopyfor SQL Server. - What are interceptors used for? Hooking into EF operations:
SaveChangesInterceptorfor audit fields or soft delete,DbCommandInterceptorfor logging or query hints. - 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.
- 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.
- How do retries interact with transactions? With
EnableRetryOnFailure, wrap a user-initiated transaction indb.Database.CreateExecutionStrategy().ExecuteAsync(...)so the whole unit retries together. - 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 nativejsontype when the compatibility level is 170 or higher. - 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. - 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
| Format | What it usually looks like | How to prepare |
|---|---|---|
| Concept Q&A | DbContext lifetime, tracking, loading strategies, migrations, concurrency | Explain each with a one-line LINQ example |
| LINQ exercise | Write a query and say what SQL it produces, or why it is slow | Practice with ToQueryString() on your own model |
| Code review | Spot N+1, early ToList, shared DbContext or a missing await | Read data-access code with those four in mind |
| Senior design | Data access layer, migration strategy, multi-tenancy, read models | Bring 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