What is DbContext in Entity Framework Core?
DbContext represents a session with the database and coordinates querying, change tracking, and saving entities.
C# interview questions covering ef core, data access & performance.
Open a question for the full answer, code and interview guidance.
DbContext represents a session with the database and coordinates querying, change tracking, and saving entities.
Change tracking allows EF Core to monitor entity instances and determine what INSERT, UPDATE, or DELETE operations are needed when SaveChanges is called.
AsNoTracking tells EF Core not to track entities returned by a query.
Eager loading retrieves related data as part of the query, commonly using Include and ThenInclude.
The N+1 problem occurs when an application executes one query to retrieve a list and then performs an additional query for each item to retrieve related data.
Projection uses Select to return only the fields required by the application instead of loading complete entity objects.
Pagination prevents large datasets from being loaded into memory or sent to the client at once.
A transaction ensures that a group of database operations succeeds or fails as a unit.
Optimistic concurrency assumes that conflicts are relatively uncommon and allows multiple users to read data without locking it for the duration of their work.
Start by measuring and inspecting the generated SQL rather than assuming EF Core itself is the problem.