Entity Framework & EF Core Interview Questions and Answers

Entity Framework Core interview questions — DbContext and change tracking, Code First vs Database First, lazy vs eager loading and the N+1 problem, and migrations.

7 questionsFree · Updated for 2026

EF Core questions reveal whether you understand what your data-access code does to the database. The recurring themes are the DbContext lifetime, change tracking, and how loading strategy causes (or avoids) the N+1 problem.

Fundamentals & modelling

3 questions
01What is Entity Framework Core?

Entity Framework Core is Microsoft's lightweight, cross-platform object-relational mapper (ORM) for .NET. It lets you work with a database using C# classes and LINQ instead of hand-written SQL: DbContext…

Read detailed answer
02What is the difference between Code First and Database First?

Code First: you write the C# entity classes and configuration, and EF generates the database schema through migrations. Database First: the database already exists and you scaffold (reverse-engineer) the…

Read detailed answer
03What is a migration in EF Core?

A migration is a versioned, code-generated description of a schema change. When you change your entity model, dotnet ef migrations add <Name> diffs the model against the last migration and writes Up()/Down()…

Read detailed answer

Querying & persistence

4 questions
04What is the difference between IEnumerable and IQueryable?

IEnumerable<T> represents an in-memory sequence; LINQ operators run as compiled delegates and iterate objects client-side. IQueryable<T> represents a query against a remote provider (e.g. a database); LINQ…

Read detailed answer
05What is the difference between lazy loading, eager loading and explicit loading?

Eager loading pulls related data in the same query using Include(). Lazy loading fetches a navigation property automatically the first time you access it — convenient but the classic cause of the N+1 query…

Read detailed answer
06What is change tracking in EF Core?

Change tracking is how EF Core knows what to save. When you query with tracking (the default), the context keeps a snapshot of each entity and assigns it a state — Unchanged, Added, Modified, Deleted. On…

Read detailed answer
07Why is DbContext registered as Scoped?

DbContext is registered as Scoped because it is a lightweight, stateful, not thread-safe unit-of-work. One instance per request lets every repository and service in that request share the same change tracker…

Read detailed answer
Back to the interview hub