0

I'm using SQL Server and Visual Studio 2013 for a specific project. I have a database (.mdf) file, which has a lot of data.

The problem is, when I modify this data, that being both via Visual Studio "Show Table Data" option or via the SQL console on Visual Studio, I get the following error when using LINQ code:

Cannot drop database "MYPROJECT_78c66be067bf45d1b143082737bed23a" because it is currently in use.

Is there a way to solve this problem?

I have several files inside my App_Data folder:

aspnet-MYPROJECT-20131223105750.mdf
aspnet-MYPROJECT-20131223105750_log.ldf
ErrorLog.txt
MYPROJECT.mdf
MYPROJECT_log.ldf

Thank you. I really need to solve this.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Make sure you log out of the database when you're finished editing. If there is no explicit logout function in VS, try using SQL Server Management Studio. – Nick.Mc Jun 23 '14 at 01:03
  • @ElectricLlama How can I logout of the database after editing using Managemet Studio? – user3763857 Jun 23 '14 at 01:07
  • I don't know sorry! But the SQL Server thinks you are still logged in and active so it can't drop the DB. That is the tehcnical reason for the error but I don't know how you force a logout from VS. If you want a practical solution you could write a batch file that forces a logout of all users and run that. But there might be something in the tool that we're all overlooking (I haven't used VS 2013) – Nick.Mc Jun 23 '14 at 01:28
  • Do you have this option in your Management Studio? **Tools->Designers->Table and Database Designers** – Ricky Jun 23 '14 at 05:22

1 Answers1

0

In Sql Server Management Studio, go to Tools->Designers->Table and Database Designers.

Uncheck Prevent saving changes that require the table re-creation option.

Note: If you disable this option, you are not warned when you save the table that the changes that you made have changed the metadata structure of the table. In this case, data loss may occur when you save the table.

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

For more info, go to this link: http://support.microsoft.com/kb/956176

Ricky
  • 2,323
  • 6
  • 22
  • 22