SQL Server Interview Question #294

What are EF Core migrations?

ASP.NET Core, EF Core & SQL Server Real-World Scenarios Senior Advanced

Detailed Explanation

Migrations provide a versioned mechanism for evolving the database schema as the EF Core model changes. A migration can contain operations such as creating tables, adding columns, indexes, constraints, and data transformations.

Production migrations should be reviewed before deployment. Automatically applying every migration at application startup can create availability, permission, locking, or rollback concerns in controlled production environments.

Teams often generate and review migration SQL as part of deployment pipelines.

Code Example

dotnet ef migrations add AddProductRating
dotnet ef database update