I am in VS 2012 RTM, with EF 5. I am doing Code First, but trying to ignore Code Migrations, since I am only in development. To avoid them, I have this set
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<SomeContext>());
Sometimes, even when I do not think that I have touched the model, he decides to recreate. It's great. But usually this leads to an error
The database cannot be deleted because it is currently in use.
So I decided to completely delete the database. I go to VS, go to "SQL Server Object Browser", find the DB and delete it. Now i'm stuck in
Unable to attach file '{0}' as database '{1}'
It happened to me last night, and I just staggered until it worked (completing tasks, rebooting VS, changing the database name and files in the web.config file, etc.
So, question 1) How do I get out of this state?
But the more important question is: how can I not get into this state at all?
Dan friedman
source share