Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4616 total questions 4516 technical 100 career & HR 4346 from PDF library

Showing 51–75 of 153

Career & HR topics

By tech stack

Junior PDF
What is .AsNoTracking()? When to use it?

.AsNoTracking() tells EF Core not to track entities in the returned query. ✅ Use when: Read-only operations Improving performance for large queries Preventing memory overhead of tracking Example: var users = context.User…

EF Core Read answer
Junior PDF
What is .AsNoTracking()?

When to use it? .AsNoTracking() tells EF Core not to track entities in the returned query. ✅ Use when: Read-only operations Improving performance for large queries Preventing memory overhead of tracking Example: var user…

EF Core Read answer
Mid PDF
How to disable change tracking globally?

Answer: You can disable tracking by default for a specific DbContext using: optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTrac king); Or per-query using .AsNoTracking(). What interviewers expect A clear…

EF Core Read answer
Mid PDF
How to manually mark an entity as Modified / Detached etc.?

Use the Entry() method: context.Entry(entity).State = EntityState.Modified; context.Entry(entity).State = EntityState.Detached; This is helpful when: You’re updating data without reloading it Working with disconnected sc…

EF Core Read answer
Junior PDF
How is concurrency handled? What is optimistic concurrency vs pessimistic concurrency?

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…

EF Core Read answer
Mid PDF
How is concurrency handled?

What is optimistic concurrency vs pessimistic concurrency? Optimistic concurrency: Assumes that conflicts are rare. EF checks for changes before saving using concurrency tokens. Pessimistic concurrency: Locks records in…

EF Core Read answer
Junior PDF
What is a concurrency token / [Timestamp] attribute?

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…

EF Core Read answer
Mid PDF
What are the types of relationships in relational databases?

EF Core supports the standard types of relationships: One-to-One (1:1) – One entity has one related entity. One-to-Many (1:N) – One entity relates to many others. Many-to-Many (M:N) – Many entities relate to many others.…

EF Core Read answer
Mid PDF
How to configure a one-to-one relationship in EF Core?

Example using Fluent API: modelBuilder.Entity<User>() .HasOne(u => u.Profile) .WithOne(p => p.User) .HasForeignKey<Profile>(p => p.UserId); Or with data annotations: public class Profile { [Key, Fore…

EF Core Read answer
Mid PDF
How to configure a one-to-many relationship?

Fluent API: modelBuilder.Entity<Blog>() .HasMany(b => b.Posts) .WithOne(p => p.Blog) .HasForeignKey(p => p.BlogId); Data annotations: public class Post { public int BlogId { get; set; } [ForeignKey("BlogId…

EF Core Read answer
Mid PDF
How to configure many-to-many (EF Core 5+)?

In EF Core 5.0+, you can define many-to-many relationships without an explicit join entity: public class Student { public ICollection<Course> Courses { get; set; } } public class Course { public ICollection<Stud…

EF Core Read answer
Mid PDF
What are join tables / linking tables? How to represent them in EF Core?

join table maps a many-to-many relationship. In EF Core: ✅ Auto-created (EF Core 5+): If you define many-to-many with ICollection<T>, EF creates the join table. 🛠 Manual (custom join entity): public class StudentC…

EF Core Read answer
Mid PDF
What are join tables / linking tables?

How to represent them in EF Core? A join table maps a many-to-many relationship. In EF Core: ✅ Auto-created (EF Core 5+): If you define many-to-many with ICollection<T>, EF creates the join table. 🛠 Manual (custom…

EF Core Read answer
Junior PDF
What are foreign keys and primary keys? How to define them via

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…

EF Core Read answer
Mid PDF
What are foreign keys and primary keys?

How to define them via annotations & 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; } […

EF Core Read answer
Junior PDF
What is a composite key? How to define composite keys in 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 =&…

EF Core Read answer
Junior PDF
What is cascade delete, and how can it be configured?

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…

EF Core Read answer
Mid PDF
What are shadow keys / foreign keys?

shadow property is a property not defined in the .NET class but exists in the EF model. Example: modelBuilder.Entity<Post>() .HasOne<Blog>() .WithMany() .HasForeignKey("BlogId"); // BlogId is a shadow FK if n…

EF Core Read answer
Mid PDF
How to handle required vs optional relationships?

In Fluent API: Required: .HasRequired(p => p.Blog) Optional: .HasOne(p => p.Blog) .WithMany() .IsRequired(false); EF infers: Reference type (e.g., Blog) → optional by default Non-nullable value type FK (e.g., int B…

EF Core Read answer
Junior PDF
What is eager loading? 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 .ThenIncl…

EF Core Read answer
Junior PDF
What is eager loading?

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(…

EF Core Read answer
Junior PDF
What is lazy loading? How to enable lazy loading in EF Core? What

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…

EF Core Read answer
Junior PDF
What is lazy loading?

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…

EF Core Read answer
Junior PDF
What is explicit loading? 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: var blog = context.Blogs.Fi…

EF Core Read answer
Junior PDF
What is explicit loading?

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…

EF Core Read answer

Entity Framework Core Entity Framework Core Tutorial · EF Core

.AsNoTracking() tells EF Core not to track entities in the returned query.

✅ Use when:

  • Read-only operations
  • Improving performance for large queries
  • Preventing memory overhead of tracking

Example:

var users = context.Users.AsNoTracking().ToList();
Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

When to use it?

.AsNoTracking() tells EF Core not to track entities in the returned query.

✅ Use when:

  • Read-only operations
  • Improving performance for large queries
  • Preventing memory overhead of tracking

Example:

var users = context.Users.AsNoTracking().ToList();

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

Answer: You can disable tracking by default for a specific DbContext using: optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTrac king); Or per-query using .AsNoTracking().

What interviewers expect

  • A clear definition tied to EF Core in Entity Framework Core projects
  • Trade-offs (performance, maintainability, security, cost)
  • When you would and would not use it in production

Real-world example

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.

How to explain in the interview

  1. Define the concept in one or two sentences.
  2. Context — where it fits in Entity Framework Core architecture.
  3. Example — a specific project, bug, or performance win.
  4. Trade-off — what you gain vs what you sacrifice.

Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

Use the Entry() method:

context.Entry(entity).State = EntityState.Modified;
context.Entry(entity).State = EntityState.Detached;

This is helpful when:

  • You’re updating data without reloading it
  • Working with disconnected scenarios (e.g., APIs)
Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

  • 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].

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

What is optimistic concurrency vs

pessimistic concurrency?

  • 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].

Permalink & share

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; }
  • 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

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

EF Core supports the standard types of relationships:

  • One-to-One (1:1) – One entity has one related entity.
  • One-to-Many (1:N) – One entity relates to many others.
  • Many-to-Many (M:N) – Many entities relate to many others.

Each of these can be configured in EF Core using navigation properties and Fluent API or

Data Annotations.

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

Example using Fluent API:

modelBuilder.Entity<User>()

.HasOne(u => u.Profile)

.WithOne(p => p.User)

.HasForeignKey<Profile>(p => p.UserId);

Or with data annotations:

public class Profile
{

[Key, ForeignKey("User")]

public int UserId { get; set; }
public User User { get; set; }
}
  • Requires a unique foreign key.
  • EF assumes optional by default unless marked as required.
Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

Fluent API:

modelBuilder.Entity<Blog>()

.HasMany(b => b.Posts)

.WithOne(p => p.Blog)

.HasForeignKey(p => p.BlogId);

Data annotations:

public class Post
{
public int BlogId { get; set; }

[ForeignKey("BlogId")]

public Blog Blog { get; set; }
}
  • A foreign key exists in the many-side entity (Post).
  • EF infers this relationship from navigation + FK.
Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

In EF Core 5.0+, you can define many-to-many relationships without an explicit join entity:

public class Student
{
public ICollection<Course> Courses { get; set; }
}
public class Course
{
public ICollection<Student> Students { get; set; }
}

EF will automatically create a join table CourseStudent behind the scenes.

If you want to customize the join table, define a join entity explicitly.
Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

join table maps a many-to-many relationship. In EF Core:

✅ Auto-created (EF Core 5+):

If you define many-to-many with ICollection<T>, EF creates the join table.

🛠 Manual (custom join entity):

public class StudentCourse
{
public int StudentId { get; set; }
public Student Student { get; set; }
public int CourseId { get; set; }
public Course Course { get; set; }
}

nd configure with Fluent API.

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

How to represent them in EF

Core?

A join table maps a many-to-many relationship. In EF Core:

✅ Auto-created (EF Core 5+):

If you define many-to-many with ICollection<T>, EF creates the join table.

🛠 Manual (custom join entity):

public class StudentCourse

public int StudentId { get; set; }

public Student Student { get; set; }

public int CourseId { get; set; }

public Course Course { get; set; }

And configure with Fluent API.

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

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);
Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

How to define them via

annotations & 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);

Permalink & share

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&lt;OrderDetail&gt;() .HasKey(od =&gt; new { od.OrderId, od.ProductId });

What interviewers expect

  • A clear definition tied to EF Core in Entity Framework Core projects
  • Trade-offs (performance, maintainability, security, cost)
  • When you would and would not use it in production

Real-world example

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.

How to explain in the interview

  1. Define the concept in one or two sentences.
  2. Context — where it fits in Entity Framework Core architecture.
  3. Example — a specific project, bug, or performance win.
  4. Trade-off — what you gain vs what you sacrifice.

Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.

Permalink & share

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:

  • Cascade
  • Restrict
  • SetNull
  • NoAction

EF Core defaults to Cascade for required relationships.

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

shadow property is a property not defined in the .NET class but exists in the EF model.

Example:

modelBuilder.Entity<Post>()

.HasOne<Blog>()

.WithMany()

.HasForeignKey("BlogId"); // BlogId is a shadow FK if not

defined in class

EF tracks it internally but you can't access it in C# code directly.

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

In Fluent API:

  • Required:

.HasRequired(p => p.Blog)

  • Optional:

.HasOne(p => p.Blog)

.WithMany()

.IsRequired(false);

EF infers:

  • Reference type (e.g., Blog) → optional by default
  • Non-nullable value type FK (e.g., int BlogId) → required

Entity Framework Core – Lazy vs

Eager vs Explicit Loading

Permalink & share

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.

Permalink & share

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.

Permalink & share

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

  • 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

ccessed.

Permalink & share

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.

Permalink & share

Entity Framework Core Entity Framework Core Tutorial · EF Core

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

Permalink & share

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:

  • 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

Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details