Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Entity Framework Core (EF Core) is a modern, lightweight, cross-platform, open-source ORM (Object-Relational Mapper) for .NET. It allows developers to interact with databases using C# objects rather than SQ…
Short answer: ORM is a technique that maps objects in code to relational database tables. EF Core implements ORM by mapping .NET classes (entities) to database tables using DbContext, DbSet, and conventions or Fluent API…
Short answer: How does EF Core implement it? ORM is a technique that maps objects in code to relational database tables. EF Core implements ORM by mapping .NET classes (entities) to database tables using DbContext, DbSet…
Short answer: DbContext is the primary class for interacting with the database in EF Core. Explain a bit more It: Manages database connections Tracks changes to entities Provides methods for querying and saving data Conf…
Short answer: What responsibilities does it have? DbContext is the primary class for interacting with the database in EF Core. It: Manages database connections Tracks changes to entities Provides methods for querying and…
Short answer: DbSet<T> represents a collection of entities of type T in the context. Each DbSet maps to a table in the database, where T is the type of the entity. Real-world example (ShopNest) ShopNest’s order ser…
Short answer: How does it map to database tables? DbSet<T> represents a collection of entities of type T in the context. Each DbSet maps to a table in the database, where T is the type of the entity. Real-world exa…
Short answer: POCO (Plain Old CLR Object) is a simple class without any dependency on EF Core or any base class. EF Core uses POCOs as entities for data modeling. Real-world example (ShopNest) ShopNest’s order service us…
Short answer: Navigation properties allow navigation from one entity to related entities. They define relationships (one-to-one, one-to-many, many-to-many). Example: public class Order Example code { public int Id { get;…
Short answer: LINQ (Language Integrated Query) lets you query collections using C# syntax. LINQ to Entities is LINQ querying against the EF Core model, translated to SQL and executed in the database. Real-world example (…
Short answer: What is “LINQ to Entities”? LINQ (Language Integrated Query) lets you query collections using C# syntax. LINQ to Entities is LINQ querying against the EF Core model, translated to SQL and executed in the da…
Short answer: The Repository pattern abstracts the data access layer from the business logic by providing a collection-like interface to access domain objects. It helps keep data access logic centralized and makes the co…
Short answer: The Unit of Work pattern is a design pattern used to maintain a list of operations to be performed within a single transaction. It ensures that all operations either succeed or fail together, providing cons…
Short answer: Dependency Injection (DI) is a design pattern that allows an object to receive its dependencies from an external source rather than creating them itself. This promotes loose coupling, enhances testability,…
Short answer: Transient: A new instance is created every time it is requested. Scoped: A single instance is created per request/HTTP request. Singleton: A single instance is created and shared across the application life…
Short answer: The Single Responsibility Principle (SRP) states that a class should have only one reason to change. In other words, it should have only one responsibility or job. Each class should do one thing, and do it…
Short answer: Before (OCP Violation): public class DiscountCalculator If you need to support a new customer type, you must modify this method — violating OCP. After (OCP Compliant): public interface IDiscountStrategy Exa…
Short answer: The Liskov Substitution Principle (LSP) states that: Subtypes must be substitutable for their base types without altering the correctness of the program. In other words, if class S is a subclass of class T,…
Short answer: Example (Violation of LSP): public class Rectangle Example code { public virtual int Width { get; set; } public virtual int Height { get; set; } public int Area() => Width * Height; } public class Square…
Short answer: The Interface Segregation Principle (ISP) states that: Clients should not be forced to depend on interfaces they do not use. This means that interfaces should be small and focused, containing only the metho…
Short answer: The Dependency Inversion Principle (DIP) states that: High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details. Details should…
Short answer: DAO (Data Access Object) focuses on low-level database operations and CRUD, typically mapping tables to objects. Repository abstracts data access at the domain level, working with aggregates/entities and en…
Short answer: IServiceCollection: A container used during app startup to register services and their lifetimes (Scoped, Transient, Singleton). It acts as a service registry. IServiceProvider: The built container that res…
Short answer: Inheritance creates an “is-a” relationship, where a subclass inherits behavior and properties from a parent class. It can lead to tight coupling and fragile hierarchies if overused. Composition creates a “h…
Short answer: Cohesion: Degree to which elements of a module belong together. High cohesion means focused, well-defined responsibilities. Coupling: Degree of interdependence between modules. Low coupling means modules ar…
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Entity Framework Core (EF Core) is a modern, lightweight, cross-platform, open-source ORM (Object-Relational Mapper) for .NET. It allows developers to interact with databases using C# objects rather than SQL queries.
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: ORM is a technique that maps objects in code to relational database tables. EF Core implements ORM by mapping .NET classes (entities) to database tables using DbContext, DbSet, and conventions or Fluent API.
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 implement it? ORM is a technique that maps objects in code to relational database tables. EF Core implements ORM by mapping .NET classes (entities) to database tables using DbContext, DbSet, and conventions or Fluent API.
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: DbContext is the primary class for interacting with the database in EF Core.
It: Manages database connections Tracks changes to entities Provides methods for querying and saving data Configures models and relationships DbContext is the primary class for interacting with the database in EF Core. It: Manages database connections Tracks changes to entities Provides methods for querying and saving data Configures models and relationships
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: What responsibilities does it have? DbContext is the primary class for interacting with the database in EF Core. It: Manages database connections Tracks changes to entities Provides methods for querying and saving data Configures models and relationships
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: DbSet<T> represents a collection of entities of type T in the context. Each DbSet maps to a table in the database, where T is the type of the entity.
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 it map to database tables? DbSet<T> represents a collection of entities of type T in the context. Each DbSet maps to a table in the database, where T is the type of the entity.
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: POCO (Plain Old CLR Object) is a simple class without any dependency on EF Core or any base class. EF Core uses POCOs as entities for data modeling.
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: Navigation properties allow navigation from one entity to related entities. They define relationships (one-to-one, one-to-many, many-to-many). Example: public class Order
{
public int Id { get; set; }
public Customer Customer { get; set; } // Navigation property
}
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: LINQ (Language Integrated Query) lets you query collections using C# syntax. LINQ to Entities is LINQ querying against the EF Core model, translated to SQL and executed in the database.
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: What is “LINQ to Entities”? LINQ (Language Integrated Query) lets you query collections using C# syntax. LINQ to Entities is LINQ querying against the EF Core model, translated to SQL and executed in the database.
ShopNest’s order service uses EF Core to save an Order and its line items in one SaveChangesAsync() call inside a transaction.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: The Repository pattern abstracts the data access layer from the business logic by providing a collection-like interface to access domain objects. It helps keep data access logic centralized and makes the codebase easier to maintain, test, and swap out data sources (e.g., switching from EF Core to Dapper or an API).
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: The Unit of Work pattern is a design pattern used to maintain a list of operations to be performed within a single transaction. It ensures that all operations either succeed or fail together, providing consistency and managing changes to multiple business objects during a transaction. It coordinates the writing out of changes and resolves potential concurrency issues.
Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: Dependency Injection (DI) is a design pattern that allows an object to receive its dependencies from an external source rather than creating them itself. This promotes loose coupling, enhances testability, and simplifies code maintenance. Benefits: Improves modularity Enables easier unit testing (via mock dependencies) Promotes adherence to SOLID principles (especially the Dependency Inversion Principle)
Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: Transient: A new instance is created every time it is requested. Scoped: A single instance is created per request/HTTP request. Singleton: A single instance is created and shared across the application lifetime. Lifetime Created Per Use Case Transient Every injection Lightweight, stateless services Scoped HTTP Request Web services handling per-request data Singleton App lifetime Logging, configuration, cache
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: The Single Responsibility Principle (SRP) states that a class should have only one reason to change. In other words, it should have only one responsibility or job. Each class should do one thing, and do it well. For example, a class that handles user authentication should not also be responsible for logging or sending emails.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: Before (OCP Violation): public class DiscountCalculator If you need to support a new customer type, you must modify this method — violating OCP. After (OCP Compliant): public interface IDiscountStrategy
{
public decimal CalculateDiscount(string customerType)
{
if (customerType == "Regular") return 10;
if (customerType == "Premium") return 20;
if (customerType == "VIP") return 30;
return 0;
}
}
{ decimal GetDiscount(); }
public class RegularCustomerDiscount : IDiscountStrategy
{
public decimal GetDiscount() => 10;
}
public class PremiumCustomerDiscount : IDiscountStrategy
{
public decimal GetDiscount() => 20;
}
public class VipCustomerDiscount : IDiscountStrategy
{
public decimal GetDiscount() => 30;
} Now you can add new customer types without modifying existing code — just create a new strategy.
Open/Closed in ShopNest: add a new payment method by adding a class, not by editing a giant switch in CheckoutService.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: The Liskov Substitution Principle (LSP) states that: Subtypes must be substitutable for their base types without altering the correctness of the program. In other words, if class S is a subclass of class T, then objects of type T should be replaceable with objects of type S without breaking the application. This ensures that inheritance models is-a relationships correctly.
Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: Example (Violation of LSP): public class Rectangle
{
public virtual int Width { get; set; }
public virtual int Height { get; set; }
public int Area() => Width * Height;
}
public class Square : Rectangle
{
public override int Width
{
set { base.Width = base.Height = value; }
}
public override int Height
{
set { base.Width = base.Height = value; }
}
} Now if you substitute Rectangle with Square: Rectangle rect = new Square();
rect.Width = 5;
rect.Height = 10; Console.WriteLine(rect.Area()); // Outputs 100, but logically expected 50 ❌ The behavior is incorrect — this is a violation of LSP.
Open/Closed in ShopNest: add a new payment method by adding a class, not by editing a giant switch in CheckoutService.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: The Interface Segregation Principle (ISP) states that: Clients should not be forced to depend on interfaces they do not use. This means that interfaces should be small and focused, containing only the methods that are relevant to the implementing class. It prevents "fat" or "bloated" interfaces.
Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: The Dependency Inversion Principle (DIP) states that: High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions. In other words: High-level business logic shouldn't depend on concrete implementations. Instead, both high- and low-level components should depend on interfaces or abstract classes.
Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: DAO (Data Access Object) focuses on low-level database operations and CRUD, typically mapping tables to objects. Repository abstracts data access at the domain level, working with aggregates/entities and encapsulating business logic. Repository often uses DAO internally but is more aligned with domain-driven design.
ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: IServiceCollection: A container used during app startup to register services and their lifetimes (Scoped, Transient, Singleton). It acts as a service registry. IServiceProvider: The built container that resolves and provides instances of registered services at runtime. It uses the registrations to create and inject dependencies.
Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: Inheritance creates an “is-a” relationship, where a subclass inherits behavior and properties from a parent class. It can lead to tight coupling and fragile hierarchies if overused. Composition creates a “has-a” relationship, where a class contains instances of other classes and delegates behavior to them. It’s more flexible and promotes loose coupling.
Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.
Design Patterns & SOLID Design Patterns in C# · SOLID
Short answer: Cohesion: Degree to which elements of a module belong together. High cohesion means focused, well-defined responsibilities. Coupling: Degree of interdependence between modules. Low coupling means modules are independent and changes in one don’t affect others.
Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.