Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Optimistic concurrency: Assumes that conflicts are rare. EF checks for changes before saving using concurrency tokens. Pessimistic concurrency: Locks records in the DB to prevent other updates (not supported out-of-the-b…
concurrency token is a property used to detect concurrency conflicts. Example with [Timestamp]: [Timestamp] public byte[] RowVersion { get; set; } EF Core includes this column in the WHERE clause of updates. If the row h…
nnotations & Fluent API? Primary Key (PK): Unique identifier of a record. Foreign Key (FK): A field that references a PK in another table. Data Annotations: [Key] public int Id { get; set; } [ForeignKey("Blog")] publ…
Answer: composite key is a primary key made of multiple columns. EF Core does not support composite keys via data annotations, so you must use Fluent PI: modelBuilder.Entity<OrderDetail>() .HasKey(od =&…
Cascade delete ensures that related entities are deleted when the parent entity is deleted. Configure with Fluent API: modelBuilder.Entity<Blog>() .HasMany(b => b.Posts) .WithOne(p => p.Blog) .OnDelete(Delete…
Eager loading loads related data as part of the initial query, reducing round-trips to the database. ✅ Use .Include() to load related entities: var blogs = context.Blogs .Include(b => b.Posts) .ToList(); Use .ThenIncl…
How is .Include() / .ThenInclude() used? Eager loading loads related data as part of the initial query, reducing round-trips to the database. ✅ Use .Include() to load related entities: var blogs = context.Blogs .Include(…
re proxies? Lazy loading delays the loading of related data until it's accessed for the first time. EF Core requires proxies for lazy loading: Install NuGet: Microsoft.EntityFrameworkCore.Proxies Enable in OnConfiguring…
How to enable lazy loading in EF Core? What are proxies? Lazy loading delays the loading of related data until it's accessed for the first time. EF Core requires proxies for lazy loading: Install NuGet: Microsoft.EntityF…
Explicit loading means loading related data manually, after the main entity is loaded. Use when: You need full control over what and when to load You don’t want automatic lazy loading Example: var blog = context.Blogs.Fi…
When & how to use it? Explicit loading means loading related data manually, after the main entity is loaded. Use when: You need full control over what and when to load You don’t want automatic lazy loading Example: v…
The N+1 problem occurs when: 1 query loads N parent entities N additional queries load related entities (1 per parent) Example (lazy loading): foreach (var blog in context.Blogs) { Console.WriteLine(blog.Owner.Name); //…
How can lazy loading lead to it? The N+1 problem occurs when: 1 query loads N parent entities N additional queries load related entities (1 per parent) Example (lazy loading): foreach (var blog in context.Blogs) Console.…
By default, EF Core uses no automatic loading — it doesn’t lazy-load or eager-load relationships unless you: Use .Include() for eager loading Enable lazy loading proxies Use .Load() for explicit loading This default avoi…
Answer: Projection transforms entities into custom shapes, e.g., DTOs. var projected = context.Products .Select(p =&gt; new { p.Name, p.Price }); Useful for: Reducing data load. Returning only needed fields. Mapping…
pplication. Pros: Decouples data access logic from business logic. Easier to mock/test. Encapsulates queries in a single place. Cons: EF Core’s DbContext already acts like a repository and unit of work. Can add unnecessa…
Why use it with EF Core (pros and cons)? Repository Pattern abstracts data access logic, exposing CRUD methods to the application. Pros: Decouples data access logic from business logic. Easier to mock/test. Encapsulates…
Answer: Unit of Work maintains a list of operations to be committed as a single transaction. EF Core’s DbContext implements Unit of Work, tracking changes and coordinating commits (SaveChanges()). What interviewers expec…
Answer: A filter automatically applied to all queries on an entity. Useful for soft deletes, multi-tenancy (filtering by tenant ID), or data partitioning. What interviewers expect A clear definition tied to EF Core in En…
Answer: When/why to use it? A filter automatically applied to all queries on an entity. Useful for soft deletes, multi-tenancy (filtering by tenant ID), or data partitioning. What interviewers expect A clear definition t…
Answer: EF Core batches multiple commands into a single database round trip when possible. Improves performance by reducing network overhead. What interviewers expect A clear definition tied to EF Core in Entity Framewor…
Answer: How does EF Core handle batch operations? EF Core batches multiple commands into a single database round trip when possible. Improves performance by reducing network overhead. What interviewers expect A clear def…
Answer: Mark entities as deleted without physically removing them. Implemented using a boolean flag and global query filters to exclude “deleted” records. What interviewers expect A clear definition tied to EF Core in En…
Answer: Implementation strategies in EF Core? Mark entities as deleted without physically removing them. Implemented using a boolean flag and global query filters to exclude “deleted” records. What interviewers expect A…
Answer: Assumes conflicts are rare; detects conflicts when saving. Uses concurrency tokens (e.g., timestamp or row version) to detect if data was changed by another process. EF Core throws DbUpdateConcurrencyException if…
Entity Framework Core Entity Framework Core Tutorial · EF Core
before saving using concurrency tokens.
supported out-of-the-box in EF Core).
EF Core supports optimistic concurrency using [ConcurrencyCheck] or
[Timestamp].
Entity Framework Core Entity Framework Core Tutorial · EF Core
concurrency token is a property used to detect concurrency conflicts.
Example with [Timestamp]:
[Timestamp]
public byte[] RowVersion { get; set; }
DbUpdateConcurrencyException.
Entity Framework Core – Relationships
Entity Framework Core Entity Framework Core Tutorial · EF Core
nnotations & Fluent API?
Data Annotations:
[Key]
public int Id { get; set; }
[ForeignKey("Blog")]
public int BlogId { get; set; }
Fluent API:
modelBuilder.Entity<Post>()
.HasKey(p => p.Id);
modelBuilder.Entity<Post>()
.HasOne(p => p.Blog)
.WithMany(b => b.Posts)
.HasForeignKey(p => p.BlogId);Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: composite key is a primary key made of multiple columns. EF Core does not support composite keys via data annotations, so you must use Fluent PI: modelBuilder.Entity<OrderDetail>() .HasKey(od => new { od.OrderId, od.ProductId });
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Cascade delete ensures that related entities are deleted when the parent entity is deleted.
Configure with Fluent API:
modelBuilder.Entity<Blog>()
.HasMany(b => b.Posts)
.WithOne(p => p.Blog)
.OnDelete(DeleteBehavior.Cascade);
Delete behaviors:
EF Core defaults to Cascade for required relationships.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Eager loading loads related data as part of the initial query, reducing round-trips to the
database.
✅ Use .Include() to load related entities:
var blogs = context.Blogs
.Include(b => b.Posts)
.ToList();
Use .ThenInclude() for deeper nesting:
context.Blogs
.Include(b => b.Posts)
.ThenInclude(p => p.Comments);
Eager loading prevents lazy load performance issues and the N+1 problem.
Entity Framework Core Entity Framework Core Tutorial · EF Core
How is .Include() / .ThenInclude()
used?
Eager loading loads related data as part of the initial query, reducing round-trips to the
database.
✅ Use .Include() to load related entities:
var blogs = context.Blogs
.Include(b => b.Posts)
.ToList();
Use .ThenInclude() for deeper nesting:
context.Blogs
.Include(b => b.Posts)
.ThenInclude(p => p.Comments);
Eager loading prevents lazy load performance issues and the N+1 problem.
Entity Framework Core Entity Framework Core Tutorial · EF Core
re proxies?
Lazy loading delays the loading of related data until it's accessed for the first time.
EF Core requires proxies for lazy loading:
Install NuGet:
Microsoft.EntityFrameworkCore.Proxies
options.UseLazyLoadingProxies();
public virtual ICollection<Post> Posts { get; set; }
ccessed.
Entity Framework Core Entity Framework Core Tutorial · EF Core
How to enable lazy loading in EF Core? What
are proxies?
Lazy loading delays the loading of related data until it's accessed for the first time.
EF Core requires proxies for lazy loading:
Install NuGet:
Microsoft.EntityFrameworkCore.Proxies
Enable in OnConfiguring or AddDbContext:
options.UseLazyLoadingProxies();
Mark navigation properties as virtual:
public virtual ICollection<Post> Posts { get; set; }
EF creates runtime proxies to override navigation properties and load them when
accessed.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Explicit loading means loading related data manually, after the main entity is loaded.
Use when:
Example:
var blog = context.Blogs.First();
context.Entry(blog)
.Collection(b => b.Posts)
.Load();
context.Entry(blog)
.Reference(b => b.Owner)
.Load();
✅ Use .Reference().Load() for single navigation
✅ Use .Collection().Load() for collections
Entity Framework Core Entity Framework Core Tutorial · EF Core
When & how to use it?
Explicit loading means loading related data manually, after the main entity is loaded.
Use when:
Example:
var blog = context.Blogs.First();
context.Entry(blog)
.Collection(b => b.Posts)
.Load();
context.Entry(blog)
.Reference(b => b.Owner)
.Load();
✅ Use .Reference().Load() for single navigation
✅ Use .Collection().Load() for collections
Entity Framework Core Entity Framework Core Tutorial · EF Core
The N+1 problem occurs when:
Example (lazy loading):
foreach (var blog in context.Blogs)
{
Console.WriteLine(blog.Owner.Name); // triggers a query for each
blog
}
This causes N+1 queries, which can hurt performance significantly.
✅ Solution: Use eager loading with .Include() to fetch everything in one query.
Entity Framework Core Entity Framework Core Tutorial · EF Core
How can lazy loading lead to it?
The N+1 problem occurs when:
Example (lazy loading):
foreach (var blog in context.Blogs)
Console.WriteLine(blog.Owner.Name); // triggers a query for each
blog
This causes N+1 queries, which can hurt performance significantly.
✅ Solution: Use eager loading with .Include() to fetch everything in one query.
Entity Framework Core Entity Framework Core Tutorial · EF Core
By default, EF Core uses no automatic loading — it doesn’t lazy-load or eager-load
relationships unless you:
This default avoids unintended queries and promotes performance control.
EF Core LINQ Queries & Querying
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Projection transforms entities into custom shapes, e.g., DTOs. var projected = context.Products .Select(p => new { p.Name, p.Price }); Useful for: Reducing data load. Returning only needed fields. Mapping to custom types.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
pplication.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Why use it with EF Core (pros and
cons)?
application.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Unit of Work maintains a list of operations to be committed as a single transaction. EF Core’s DbContext implements Unit of Work, tracking changes and coordinating commits (SaveChanges()).
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: A filter automatically applied to all queries on an entity. Useful for soft deletes, multi-tenancy (filtering by tenant ID), or data partitioning.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: When/why to use it? A filter automatically applied to all queries on an entity. Useful for soft deletes, multi-tenancy (filtering by tenant ID), or data partitioning.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: EF Core batches multiple commands into a single database round trip when possible. Improves performance by reducing network overhead.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: How does EF Core handle batch operations? EF Core batches multiple commands into a single database round trip when possible. Improves performance by reducing network overhead.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Mark entities as deleted without physically removing them. Implemented using a boolean flag and global query filters to exclude “deleted” records.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Implementation strategies in EF Core? Mark entities as deleted without physically removing them. Implemented using a boolean flag and global query filters to exclude “deleted” records.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Assumes conflicts are rare; detects conflicts when saving. Uses concurrency tokens (e.g., timestamp or row version) to detect if data was changed by another process. EF Core throws DbUpdateConcurrencyException if a conflict occurs.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.