EF5: Cannot attach the file ‘{0}' as database '{1}'
If you delete the DB file, it still stays registered with SqlLocalDB. Sometimes it fixes it to delete the DB. You can do this from the command line.
- Open the "Developer Command Propmpt for VisualStudio" under your start/programs menu.
Run the following commands:
sqllocaldb.exe stop v11.0
sqllocaldb.exe delete v11.0
For those still searching for a solution...
Go to View / SQL Server Object Explorer and delete the database from the (localdb)\v11.0 subnode!
There is essentially a local database retained of where the files should be, and if you want to delete the database files make sure you remove them from this explorer utility, not manually.
I did try JSobell's solution first but did not see my database listed there. I ran CodingWithSpike's commands from VS Developer Command Prompt, but that did not work either. Finally I ran CodingWithSpike's same commands from Package Manager Console and that worked.
PM> sqllocaldb.exe stop v11.0 LocalDB instance "v11.0" stopped. PM> PM> sqllocaldb.exe delete v11.0 LocalDB instance "v11.0" deleted. PM> sqllocaldb.exe start v11.0 LocalDB instance "v11.0" started.