How to unapply a migration in ASP.NET Core with EF Core

Use:

CLI

> dotnet ef database update <previous-migration-name>

Package Manager Console

PM> Update-Database <previous-migration-name>

Example:

PM> Update-Database MyInitialMigration

Then try to remove last migration.

Removing migration without database update doesn't work because you applied changes to database.

If using PMC, Try: PM> update-database 0 This will wipe the database and allow you to remove the Migration Snapshot on your Solution


To completely remove all migrations and start all over again, do the following:

dotnet ef database update 0
dotnet ef migrations remove