Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Entities are .NET classes that represent database tables. Each property in the entity maps to a column. EF Core uses conventions or Fluent API to configure the mappings. Real-world example (ShopNest) ShopNe…
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: Scalar: Simple types like int, string, DateTime Complex: Nested objects mapped to multiple columns (Value objects) Shadow: Properties not defined in the .NET class but tracked by EF Core Real-world example…
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: // Create context.Users.Add(new User { Name = "John" }); context.SaveChanges(); // Read var user = context.Users.FirstOrDefault(u => u.Id == 1); // Update user.Name = "Jane"; context.…
Short answer: Productivity via abstraction from SQL Cross-platform support Strongly-typed LINQ queries Migration support Tracks changes automatically Works well with dependency injection Real-world example (ShopNest) Sho…
Short answer: May generate inefficient SQL for complex queries Learning curve for advanced features Less control over fine-tuned SQL performance Not ideal for high-performance bulk operations Entity Framework Core – Sche…
Short answer: Code First is an EF Core approach where you define your database schema using C# classes, and EF Core generates the database from your code. ✅ Advantages: Full control via C# code (POCOs) Easily version-con…
Short answer: Advantages and when to use it Code First is an EF Core approach where you define your database schema using C# classes, and EF Core generates the database from your code. ✅ Advantages: Full control via C# c…
Short answer: Database First involves generating C# entity classes and a DbContext from an existing database. ✅ Pros: Quick start if the DB already exists Ensures model aligns with legacy databases ❌ Cons: Harder to vers…
Short answer: Use‑cases and pros and cons Database First involves generating C# entity classes and a DbContext from an existing database. ✅ Pros: Quick start if the DB already exists Ensures model aligns with legacy data…
Short answer: Model First allows creating a database model using a designer (EDMX file), then generating both the database and code from that model. ⚠ EF Core does not support Model First. This approach was available in…
Short answer: Is it used in EF Core? Model First allows creating a database model using a designer (EDMX file), then generating both the database and code from that model. ⚠ EF Core does not support Model First. This app…
Short answer: Use the CLI or Package Manager Console: dotnet ef dbcontext scaffold "YourConnectionString" Microsoft.EntityFrameworkCore.SqlServer -o Models OR Scaffold-DbContext "YourConnectionString"…
Short answer: EF Core uses migrations to track and apply schema changes: You modify your C# models. Use Add-Migration to create a migration class. Use Update-Database to apply the changes to the DB. EF Core compares the…
Short answer: 🧩 Data Annotations (in the entity class): [Table("Users")] public class User Example code { [Key] public int Id { get; set; } [Column("UserName")] public string Name { get; set; } } 🧠…
Short answer: Migrations in EF Core are a way to: Track schema changes over time Apply those changes to the database 📦 Basic commands: Add-Migration MigrationName Update-Database Remove-Migration Script-Migration 🔄 Mig…
Short answer: How are they used in Code First? Migrations in EF Core are a way to: Track schema changes over time Apply those changes to the database 📦 Basic commands: Add-Migration MigrationName Update-Database Remove-…
Short answer: dd-Migration MigrationName This creates a migration file with Up() and Down() methods, and a snapshot of the current model. Real-world example (ShopNest) When ShopNest adds a DiscountCode column, you create…
Short answer: (e.g. Add-Migration) Use one of the following commands: .NET CLI: dotnet ef migrations add MigrationName Package Manager Console: Add-Migration MigrationName This creates a migration file with Up() and Down…
Short answer: pply the migration to your database using: .NET CLI: dotnet ef database update Package Manager Console: Update-Database EF Core translates your model changes into SQL and executes them against the database.…
Short answer: (e.g. Update-Database) Apply the migration to your database using: .NET CLI: dotnet ef database update Package Manager Console: Update-Database EF Core translates your model changes into SQL and executes th…
Short answer: A migration snapshot is a C# file (e.g., ModelSnapshot.cs) automatically created by EF Core. It represents the current model state. EF uses it to compare changes in future migrations. Located in the Migrati…
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: Entities are .NET classes that represent database tables. Each property in the entity maps to a column. EF Core uses conventions or Fluent API to configure the mappings.
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: Scalar: Simple types like int, string, DateTime Complex: Nested objects mapped to multiple columns (Value objects) Shadow: Properties not defined in the .NET class but tracked by EF Core
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.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: // Create context.Users.Add(new User { Name = "John" }); context.SaveChanges(); // Read var user = context.Users.FirstOrDefault(u => u.Id == 1); // Update user.Name = "Jane"; context.SaveChanges(); // Delete context.Users.Remove(user); context.SaveChanges();
// Create context.Users.Add(new User { Name = "John" }); context.SaveChanges(); // Read var user = context.Users.FirstOrDefault(u => u.Id == 1); // Update user.Name = "Jane"; context.SaveChanges(); // Delete context.Users.Remove(user); context.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: Productivity via abstraction from SQL Cross-platform support Strongly-typed LINQ queries Migration support Tracks changes automatically Works well with dependency injection
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: May generate inefficient SQL for complex queries Learning curve for advanced features Less control over fine-tuned SQL performance Not ideal for high-performance bulk operations Entity Framework Core – Schema Design & Migrations Interview Questions
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: Code First is an EF Core approach where you define your database schema using C# classes, and EF Core generates the database from your code. ✅ Advantages: Full control via C# code (POCOs) Easily version-controlled Supports migrations to handle schema evolution Works well with Domain-Driven Design 📌 When to use: When you're starting a new project or prefer designing schema in code.
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: Advantages and when to use it Code First is an EF Core approach where you define your database schema using C# classes, and EF Core generates the database from your code. ✅ Advantages: Full control via C# code (POCOs) Easily version-controlled Supports migrations to handle schema evolution Works well with Domain-Driven Design 📌 When to use: When you're starting a new project or prefer designing schema in code.
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: Database First involves generating C# entity classes and a DbContext from an existing database. ✅ Pros: Quick start if the DB already exists Ensures model aligns with legacy databases ❌ Cons: Harder to version control Schema changes must be manually re-scaffolded 📌 When to use: For integrating with existing databases or legacy systems.
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: Use‑cases and pros and cons Database First involves generating C# entity classes and a DbContext from an existing database. ✅ Pros: Quick start if the DB already exists Ensures model aligns with legacy databases ❌ Cons: Harder to version control Schema changes must be manually re-scaffolded 📌 When to use: For integrating with existing databases or legacy systems.
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: Model First allows creating a database model using a designer (EDMX file), then generating both the database and code from that model. ⚠ EF Core does not support Model First. This approach was available in EF6 with Visual Studio tooling.
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: Is it used in EF Core? Model First allows creating a database model using a designer (EDMX file), then generating both the database and code from that model. ⚠ EF Core does not support Model First. This approach was available in EF6 with Visual Studio tooling.
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: Use the CLI or Package Manager Console: dotnet ef dbcontext scaffold "YourConnectionString" Microsoft.EntityFrameworkCore.SqlServer -o Models OR Scaffold-DbContext "YourConnectionString" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models ✅ It generates: Entity classes DbContext class Mappings based on database schema
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: EF Core uses migrations to track and apply schema changes: You modify your C# models. Use Add-Migration to create a migration class. Use Update-Database to apply the changes to the DB. EF Core compares the model to the current schema to generate SQL.
When ShopNest adds a DiscountCode column, you create a migration, review the SQL, then apply it on staging before production.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: 🧩 Data Annotations (in the entity class): [Table("Users")] public class User
{ [Key] public int Id { get; set; } [Column("UserName")] public string Name { get; set; }
} 🧠 Fluent API (in OnModelCreating): modelBuilder.Entity<User>() .ToTable("Users") .HasKey(u => u.Id); modelBuilder.Entity<User>() .Property(u => u.Name) .HasColumnName("UserName"); 📌 Fluent API is more powerful and flexible, preferred for complex configurations.
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: Migrations in EF Core are a way to: Track schema changes over time Apply those changes to the database 📦 Basic commands: Add-Migration MigrationName Update-Database Remove-Migration Script-Migration 🔄 Migrations are classes containing Up() and Down() methods (for applying and reverting changes). 📌 They are essential for schema versioning in Code First. Entity Framework Core – Migrations Interview Questions
When ShopNest adds a DiscountCode column, you create a migration, review the SQL, then apply it on staging before production.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: How are they used in Code First? Migrations in EF Core are a way to: Track schema changes over time Apply those changes to the database 📦 Basic commands: Add-Migration MigrationName Update-Database Remove-Migration Script-Migration 🔄 Migrations are classes containing Up() and Down() methods (for applying and reverting changes). 📌 They are essential for schema versioning in Code First. Entity Framework Core –…
When ShopNest adds a DiscountCode column, you create a migration, review the SQL, then apply it on staging before production.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: dd-Migration MigrationName This creates a migration file with Up() and Down() methods, and a snapshot of the current model.
When ShopNest adds a DiscountCode column, you create a migration, review the SQL, then apply it on staging before production.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: (e.g. Add-Migration) Use one of the following commands: .NET CLI: dotnet ef migrations add MigrationName Package Manager Console: Add-Migration MigrationName This creates a migration file with Up() and Down() methods, and a snapshot of the current model.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: pply the migration to your database using: .NET CLI: dotnet ef database update Package Manager Console: Update-Database EF Core translates your model changes into SQL and executes them against the database.
When ShopNest adds a DiscountCode column, you create a migration, review the SQL, then apply it on staging before production.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: (e.g. Update-Database) Apply the migration to your database using: .NET CLI: dotnet ef database update Package Manager Console: Update-Database EF Core translates your model changes into SQL and executes them against the database.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Short answer: A migration snapshot is a C# file (e.g., ModelSnapshot.cs) automatically created by EF Core. It represents the current model state. EF uses it to compare changes in future migrations. Located in the Migrations folder, named like [YourDbContext]ModelSnapshot.cs.