Cannot drop the database 'DB', because it does not exist or you do not have permission

c# database entity-framework-6 visual-studio-2013

Question

I am working a school project with three other group members. We are using Microsoft Visual Studio 2013, and using Visual Studio Online as version control. The project is worked with .Net MVC 5 EF6. Our group is having troubles that we cannot figure out.

Here is the problem we are having. Every time that one of use grabs the newest version control changes and attempts to run the project with or without debug we get an error in browser:

"Cannot drop the database 'DB', because it does not exist or you do not have permission."

We can get it to work if we add a migration and update database. But this is causing us to have to migrate way to often and causing a lot of headaches.

We cannot figure out if we have a setting messed up or something else. I am hoping that someone can help us resolve this issue so we can get back to working more efficiently.

Also site and DB are hosted on goDaddy.

1
1
4/7/2015 3:16:21 AM

Accepted Answer

My bet is that you have AutomaticMigrationsEnabled set to true, otherwise your application wouldn't be trying to do anything with your database just because you pulled the latest version from TFS.

Also, automatic migrations don't try to drop your database, not unless your have DropCreateDatabaseWhenModelChanges or DropCreateDatabaseAlways database initializers set up. Check your code. You probably have. Here's an article. Please do not have these on production.

Also, your villain database initializer isn't being able to do it's job because the ASP.NET user on GoDaddy probably doesn't have permission to do so.

My advice: Disable AutomaticMigrationsEnabled. Do you migrations manually with add-migration and update-database. AutomaticMigrationsEnabled is not a good practice. It's even being discontinued from EF7. That should solve your problem.

3
4/7/2015 3:16:00 AM

Popular Answer

I'm not sure which is worse: using GoDaddy as an ISP, or using VSS/TFS for version control :(

ANYWAY - Two suggestions:

1) Use local workspaces (and just checkin/checkout updates when you wish to synchronize):

https://msdn.microsoft.com/en-us/library/bb892960.aspx

2) See if VSO supports a macro or script to "kill all" connections before you sync versions:

https://social.msdn.microsoft.com/Forums/en-US/b41a7376-d5cd-4339-92b3-158e88a96dff/how-can-i-kill-all-connections-of-users-to-my-sql-server-database-?forum=adodotnetentityframework



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow