Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Feature EF6 EF Core Platform .NET Framework only Cross-platform (.NET Core) Performance Slower Faster and more optimized LINQ support Limited Enhanced Change tracking Basic More efficient Migrations Available Improved an…
column. EF Core uses conventions or Fluent API to configure the mappings. What interviewers expect A clear definition tied to EF Core in Entity Framework Core projects Trade-offs (performance, maintainability, security,…
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. What interviewers expect A clear definitio…
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 What interviewers expect…
Answer: Productivity via abstraction from SQL Cross-platform support Strongly-typed LINQ queries Migration support Tracks changes automatically Works well with dependency injection What interviewers expect A clear defini…
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 &…
Use the CLI or Package Manager Console: dotnet ef dbcontext scaffold "YourConnectionString" Microsoft.EntityFrameworkCore.SqlServer -o Models OR Scaffold-DbContext "YourConnectionString" Microsoft.EntityFrameworkCore.Sql…
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 c…
🧩 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.E…
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 cl…
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 Scri…
Answer: dd-Migration MigrationName This creates a migration file with Up() and Down() methods, and a snapshot of the current model. What interviewers expect A clear definition tied to EF Core in Entity Framework Core pro…
(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, an…
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. What…
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 aga…
Answer: To remove the last migration before applying it: dotnet ef migrations remove To rollback the database to a previous migration: dotnet ef database update MigrationName To rollback all migrations: dotnet ef databas…
Answer: Generate SQL script using: dotnet ef migrations script To script a specific range: dotnet ef migrations script FromMigration ToMigration These scripts are useful for deploying to production environments or execut…
How to generate SQL scripts for migrations? Generate SQL script using: dotnet ef migrations script To script a specific range: dotnet ef migrations script FromMigration ToMigration These scripts are useful for deploying…
Answer: Use the HasData() method in OnModelCreating(): modelBuilder.Entity<User>().HasData( new User { Id = 1, Name = "Admin" } ); Data is inserted automatically during Update-Database. Changes to seed data…
Best practices: Communicate and coordinate migration changes. Always pull and apply the latest migrations before adding a new one. If conflicts arise: Resolve merge conflicts in migration files manually. Rebuild ModelSna…
Generate SQL script from tested migrations. Manually review and apply via DBA or DevOps tools. Use EF Core tools in CI/CD (e.g., GitHub Actions, Azure DevOps): dotnet ef database update --no-build ● Always backup the dat…
Answer: Scaffolded migrations are the automatically generated classes that contain Up() and Down() methods. They are generated based on model differences. You can manually edit these files to: Add custom SQL Rename colum…
You can manually edit migration files after scaffolding: protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql("UPDATE Users SET IsActive = 1 WHERE IsActive IS NULL"); } Add indexes, constr…
dded New entity to be inserted into the database Modified Entity has been changed and will be updated Deleted Entity will be deleted from the database Detached Entity is not tracked by the context Unchange No changes hav…
EF Core uses these EntityState values: State Description Added New entity to be inserted into the database Modified Entity has been changed and will be updated Deleted Entity will be deleted from the database Detached En…
Entity Framework Core Entity Framework Core Tutorial · EF Core
Feature EF6 EF Core
Platform .NET Framework only Cross-platform (.NET Core)
Performance Slower Faster and more optimized
LINQ support Limited Enhanced
Change
tracking
Basic More efficient
Migrations Available Improved and CLI-friendly
Extensibility Limited Highly extensible
Entity Framework Core Entity Framework Core Tutorial · EF Core
column. EF Core uses conventions or Fluent API to configure the mappings.
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: 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.
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: 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
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: Productivity via abstraction from SQL Cross-platform support Strongly-typed LINQ queries Migration support Tracks changes automatically Works well with dependency injection
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
Entity Framework Core – Schema Design &
Migrations Interview Questions
Entity Framework Core Entity Framework Core Tutorial · EF Core
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 Framework Core Entity Framework Core Tutorial · EF Core
EF Core uses migrations to track and apply schema changes:
EF Core compares the model to the current schema to generate SQL.
Entity Framework Core Entity Framework Core Tutorial · EF Core
🧩 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.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Migrations in EF Core are a way to:
📦 Basic commands:
🔄 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 QuestionsEntity Framework Core Entity Framework Core Tutorial · EF Core
How are they used in Code First?
Migrations in EF Core are a way to:
📦 Basic commands:
🔄 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
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: dd-Migration MigrationName This creates a migration file with Up() and Down() methods, and a snapshot of the current model.
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
(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
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.
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: (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.
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: To remove the last migration before applying it: dotnet ef migrations remove To rollback the database to a previous migration: dotnet ef database update MigrationName To rollback all migrations: dotnet ef database update 0
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: Generate SQL script using: dotnet ef migrations script To script a specific range: dotnet ef migrations script FromMigration ToMigration These scripts are useful for deploying to production environments or executing via CI/CD pipelines.
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
How to generate SQL scripts for
migrations?
Generate SQL script using:
dotnet ef migrations script
To script a specific range:
dotnet ef migrations script FromMigration ToMigration
These scripts are useful for deploying to production environments or executing via CI/CD
pipelines.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Use the HasData() method in OnModelCreating(): modelBuilder.Entity<User>().HasData( new User { Id = 1, Name = "Admin" } ); Data is inserted automatically during Update-Database. Changes to seed data require a new migration.
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
Best practices:
Entity Framework Core Entity Framework Core Tutorial · EF Core
Use EF Core tools in CI/CD (e.g., GitHub Actions, Azure DevOps):
dotnet ef database update --no-build
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Scaffolded migrations are the automatically generated classes that contain Up() and Down() methods. They are generated based on model differences. You can manually edit these files to: Add custom SQL Rename columns Seed data, etc.
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
You can manually edit migration files after scaffolding:
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("UPDATE Users SET IsActive = 1 WHERE
IsActive IS NULL");
}
Entity Framework Core – Change
Tracking & Concurrency
Entity Framework Core Entity Framework Core Tutorial · EF Core
dded New entity to be inserted into the database
Modified Entity has been changed and will be updated
Deleted Entity will be deleted from the database
Detached Entity is not tracked by the context
Unchange
No changes have been made since it was
loaded
You can check/set the state via:
context.Entry(entity).State = EntityState.Modified;Entity Framework Core Entity Framework Core Tutorial · EF Core
EF Core uses these EntityState values:
State Description
Added New entity to be inserted into the database
Modified Entity has been changed and will be updated
Deleted Entity will be deleted from the database
Detached Entity is not tracked by the context
Unchange
No changes have been made since it was
loaded
You can check/set the state via:
context.Entry(entity).State = EntityState.Modified;