Tutorials Entity Framework Core Tutorial
Update Database with EF Core Migrations
Update Database with EF Core Migrations: free step-by-step lesson with examples, common mistakes, and interview tips — part of Entity Framework Core Tutorial on Toolliyo Academy.
On this page
Entity Framework Core Tutorial · Lesson 16 of 100
Update Database with EF Core Migrations
Beginner → Intermediate → Advanced → Professional
Beginner · 1 — Foundations · ~6 min · Module 2: Code First Approach
What is this?
dotnet ef database update applies pending migrations to a target database, executing each Up() method and recording names in __EFMigrationsHistory.
Why should you care?
When a teammate pulls new ShopNest migrations, they run database update so LocalDB matches yours before testing checkout.
See it live — copy this example
Paste into a .NET project with EF Core packages, then run with LocalDB/SQL Server (dotnet ef / dotnet run).
dotnet ef database update \
--project ShopNest.Infrastructure \
--startup-project ShopNest.Api
# Roll back one step in dev only:
dotnet ef database update AddCategories \
--project ShopNest.Infrastructure \
--startup-project ShopNest.Api
What happened?
- update runs all pending migrations in order.
- Rolling back to a prior name executes Down() methods — use cautiously outside dev.
Practice next
- Run database update against LocalDB ShopNest database.
- Open SSMS and confirm Products and __EFMigrationsHistory tables.
- Simulate new teammate: clone repo, restore, update, verify CanConnectAsync.
- Run dotnet ef migrations list to see applied vs pending.
- Target a different connection with --connection for a staging smoke test.
Remember
database update applies pending migrations. __EFMigrationsHistory tracks applied names. Rollback is a dev convenience, not a production habit.
ShopNest onboarding database
New developer runs dotnet ef database update and gets full schema plus seed from migrations.
Outcome: Fifteen-minute setup instead of restoring a mystery .bak file.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!