Reset EF code-first database in LocalDB

angularsen picture angularsen · Jul 3, 2012 · Viewed 8.3k times · Source

I am using Entity Framework 5.0 RC with the LocalDB database that comes pre-configured with VS 2012 RC for some prototyping and testing of code-first database.

After a few cycles of changing my code-first database and running "update-database" I did a huge breaking change and automatic migration failed bad. I don't care about resolving this conflict since this is just prototyping, so losing data is fine.

How do I reset or delete the database? Reset must also reset the migration table, which seems to be hidden from Server Explorer in Visual Studio.

Answer

Nico picture Nico · Dec 10, 2013

Drop the whole database in Visual Studio

  1. Open SQL Server Object Explorer
  2. Find the database you are working with Right click and select delete
  3. Select the two check boxes (Delete backup and restore history, and Close existing connections) and click ok
  4. Run program again and it should recreate the dabase