I ultimately ended up implementing what I described above in the question itself. All this was done AFTER migrating everything to EF6.
In my case I not only needed to apply this to my local database but to a live database as well.
The steps I used to accomplish that where the following (hopefully I'm not forgetting any, since this was a while back):
Backup your databases (both local and live), just in case you need to undo this.
First we need to create one merged migration for the entire database.
- Change your
ConnectionString
to point to a new blank database.
- Physically delete all migrations from your solution, as well as your initial creation one.
- Run
Add-Migration InitialCreate
, which should add a migration to regenerate the entire database.
Now you don't really want to run that migration. In my case I only need that for unit tests, or to create new databases from scratch.
So then we continue:
- Change your
ConnectionString
back to your local database.
- Physically delete the
MigrationHistory
table in the database (or possibly just remove the rows, I can't recall exactly).
- Comment out ALL the code whithin the
InitialCreate
migration, to make sure it will do nothing when applied.
- Run
Update-Database
, which should add an entry to the MigrationHistory
table simulating an initial creation of the database.
- Uncomment the code in the
InitialCreate
migration.
The same process can be applied for the Live database. You can point to it in the ConnString, manually remove migration history, comment the implementation of the migration and apply it, to simulate creation, then uncomment.
From then on, the database and migrations should be in sync, and unit tests (on a separate database) should be able to call Down() and Up() on all migrations and still function properly.