Is it possible to remove an EF Core Database migration after the database is updated with the same

Viewed 193

In .NET EF core, Is it possible to remove/revert a Database migration after the database is updated by "Update-database" command?

1 Answers

Yes, it's possible, but only if it is the last migration or if you revert all migrations after it.

To revert all migrations including the desired, use the -Migration parameter of the same Update-Database command and pass the name/id of the migration before the desired (or special value 0 if it is the first)

Update-Database MigrationBeforeTheOneYouWantToRevert

For more info, see Applying Migrations - Command-line tools sections of the official EF Core documentation.

Related