Run
Update-Database -Script -SourceMigration:0
to generate a SQL script for your database.
You'll then need to pick through the script to find the
CREATE TABLE
and
INSERT
statements for the
_MigrationHistory
table, and run just those statements against your database.
NB: If you've only deleted the data, and the
_MigrationHistory
table still exists, you'll only need the
INSERT
statements.
If all of your databases are already up-to-date, you could also try the approach described by Rick Strahl:
Resetting Entity Framework Migrations to a clean Slate - Rick Strahl's Web Log[
^]
But pay attention to the warning:
Quote:
Once the updates are applied your migration starting points are either no database at all, or the database in the fully updated base state. If you have databases that were a few iterations behind in migrations before you started the clean slate operations, there will be no easy way to get those in sync.
Once you've fixed the problem, back up your database and set up a scheduled job to keep it backed up. Next time you have a problem like this, you will simply be able to restore from the last good backup.