For some code-first database prototype and testing, I'm utilizing Entity Framework 5.0 RC with the LocalDB database that comes pre-configured with Visual Studio 2012 RC.
I made a significant breaking change after a few iterations of updating my code-first database and the automated migration failed miserably. Since this is simply a prototype, I don't care whether the issue is resolved, therefore losing data is OK.
How can I clear the database or reset it? Reset must also reset the migration table, which Visual Studio's Server Explorer seems to have obscured.
In Visual Studio, drop the whole database there.
This is the finest strategy I have come across thus far.
See this piece for information on how to modify the __MigrationHistory table to support both new databases built using code-first and existing databases.
The SQL script looks like this:
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?";
Because my Visual Studio 11 RC copy won't allow me to run queries on LocalDB for some reason, I'm using Free Database.NET v4 to execute this SQL script. Due to certain foreign keys, I also need to execute the script twice for it to delete all tables. Since it seems to be functioning adequately as is, I have chosen not to modify it.