Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: 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 supporte…
Short answer: A 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 updat…
Short answer: 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…
Short 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 => ne…
Short answer: How to define composite keys in EF Core? A 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 API: modelBuilder.Ent…
Short answer: 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) .O…
Short answer: 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();…
Short answer: 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.B…
Short answer: 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…
Short answer: 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: Mic…
Short answer: Explicit loading means loading related data manually, after the main entity is loaded. Explain a bit more Use when: You need full control over what and when to load You don’t want automatic lazy loading var…
Short answer: 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 load…
Short answer: 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.Ow…
Short answer: 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.B…
Short answer: 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 Thi…
Short answer: Projection transforms entities into custom shapes, e.g., DTOs. var projected = context.Products Example code .Select(p => new { p.Name, p.Price }); Useful for: Reducing data load. Returning only needed f…
Short answer: 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…
Short answer: 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.…
Short 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()). Real-world exampl…
Short answer: A filter automatically applied to all queries on an entity. Useful for soft deletes, multi-tenancy (filtering by tenant ID), or data partitioning. Real-world example (ShopNest) ShopNest’s order service uses…
Short 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. Real-world example (ShopNest) ShopNest’…
Short answer: EF Core batches multiple commands into a single database round trip when possible. Improves performance by reducing network overhead. Real-world example (ShopNest) ShopNest’s order service uses EF Core to s…
Short 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. Real-world example (ShopNest)…
Short answer: Mark entities as deleted without physically removing them. Implemented using a boolean flag and global query filters to exclude “deleted” records. Real-world example (ShopNest) ShopNest’s order service uses…
Short 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. Real-world example (S…
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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-box in EF Core). EF Core supports optimistic concurrency using [ConcurrencyCheck] or [Timestamp].
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: A 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 has changed since it was loaded, EF will throw a DbUpdateConcurrencyException. Entity Framework Core – Relationships
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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")] 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);…
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short 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 }); composite key is a primary key made of multiple columns.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: How to define composite keys in EF Core? A 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 API: modelBuilder.Entity<OrderDetail>() .HasKey(od => new { od.OrderId, od.ProductId });
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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: Cascade Restrict SetNull NoAction EF Core defaults to Cascade for required relationships.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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.
Loading orders with items uses .Include(o => o.Items). Without Include, listing 50 orders can trigger 50 extra queries (N+1).
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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…
Loading orders with items uses .Include(o => o.Items). Without Include, listing 50 orders can trigger 50 extra queries (N+1).
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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 or AddDbContext: options.UseLazyLoadingProxies(); Mark navigation properties as virtual: public virtual ICollection<Post>… Posts { get;…… set;… } EF creates runtime proxies to override navigation…
Loading orders with items uses .Include(o => o.Items). Without Include, listing 50 orders can trigger 50 extra queries (N+1).
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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.
Loading orders with items uses .Include(o => o.Items). Without Include, listing 50 orders can trigger 50 extra queries (N+1).
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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 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 Explicit loading means loading related data manually, after the main entity is loaded. 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
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 Explicit loading means loading related data manually, after the main entity is loaded. 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.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 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.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
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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
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
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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); // 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. 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); // 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.
Loading orders with items uses .Include(o => o.Items). Without Include, listing 50 orders can trigger 50 extra queries (N+1).
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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.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…
Loading orders with items uses .Include(o => o.Items). Without Include, listing 50 orders can trigger 50 extra queries (N+1).
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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 avoids unintended queries and promotes performance control. EF Core LINQ Queries & Querying
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short 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.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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 unnecessary abstraction and boilerplate. May limit EF Core’s powerful querying features.
ShopNest registers AppDbContext as scoped. One HTTP request = one context. Never inject it as a singleton.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 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 queries in a single place. Cons: EF Core’s DbContext already acts like a repository and unit of work. Can add unnecessary abstraction and boilerplate. May limit EF Core’s powerful querying features.
ShopNest registers AppDbContext as scoped. One HTTP request = one context. Never inject it as a singleton.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short 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()).
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: A filter automatically applied to all queries on an entity. Useful for soft deletes, multi-tenancy (filtering by tenant ID), or data partitioning.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short 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.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: EF Core batches multiple commands into a single database round trip when possible. Improves performance by reducing network overhead.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short 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.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Mark entities as deleted without physically removing them. Implemented using a boolean flag and global query filters to exclude “deleted” records.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short 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.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.