Entity Framework Core Interview Question #81

What does Update-Database do in EF Core?

Migrations, Database Schema & Data Management Mid-Level Intermediate

Quick Interview Answer

Update-Database applies migrations to the configured database until it reaches the requested migration, or the latest migration when no target is specified.

Detailed Explanation

Update-Database applies migrations to the configured database until it reaches the requested migration, or the latest migration when no target is specified.

The command uses the application's EF Core configuration and connection information, so developers must verify which environment and database are being targeted before running it.

For production systems, migrations are often applied through a controlled release process rather than manually from a developer workstation.

Code Example

# Package Manager Console
Update-Database

# Move to a specific migration
Update-Database AddProductInventory