Entity Framework Core Interview Question #14
What is a migration in EF Core?
EF Core Fundamentals & DbContext Junior Beginner
Quick Interview Answer
A migration is a versioned description of changes needed to move a database schema from one model state to another.
Detailed Explanation
A migration is a versioned description of changes needed to move a database schema from one model state to another.
When the EF Core model changes, a migration can contain operations such as creating tables, adding columns, creating indexes, changing constraints, or dropping objects. Migrations also maintain model metadata so EF Core can determine future differences.
Migrations should be reviewed before production deployment because generated schema changes can have performance, compatibility, and data-loss implications.
Code Example
dotnet ef migrations add AddProducts
dotnet ef database update