Catalin
Catalin

Reputation: 11731

EF Code First Migrations - should I remove migrations after downgrade?

I am using EF Code First with Migrations.

After i downgrade to a migration version, should i delete all the others that has been created after that?

Upvotes: 1

Views: 787

Answers (1)

Rusty Divine
Rusty Divine

Reputation: 3492

Deleting the forward-migrations will work just fine, if that's what you'd like to do. The next time you run an add-migration, it will find what has changed in comparison to the now-current migration. One thing I can think of is that if you are working in a team, you'll need to make sure everyone is on board with deleting the forward-migrations at the same time.

When you downgrade, the "Down" method is ran in each of the forward-migrations, and also they are removed from the _MigrationHistory table.

Alternatively, you could change your model back to what it was at your target migration and then do an add-migration - that will effectively revert your database.

Upvotes: 1

Related Questions