简体   繁体   中英

Connections to SQL Server database files (.mdf) require LocalDB or SQL Server Express to be installed and running on the local computer

I am using Visual Studio 2015 professional. When I tried to add Service-based Database to my project I got this error.

Connections to SQL Server database files (.mdf) require LocalDB or SQL Server Express to be installed and running on the local computer. You may need to modify the setup and ensure Microsoft SQL Server Data Tools is selected and install the current version at: http://go.microsoft.com/fwlink/?Linkid=125883

I also have Microsoft SQL Sever 2014 installed on my computer. really need help.

Just in case it helps others, I recently received this error in Visual Studio. The error states to go to http://go.microsoft.com/fwlink/?Linkid=125883 . When going to this URL, it now redirects to https://www.microsoft.com/en-us/server-cloud/products/sql-server/ . The new URL do not seems to have an obvious instructions on how to get Microsoft SQL Server Data Tools. Here is what worked for me.

  1. In Visual Studio, select Tools > Extensions and Updates
  2. In the Extensions and Updates pop-up box , select Installed > Updates
  3. Highlight Microsoft SQL Server Update for database... and click the Update button. If Microsoft SQL Server Update for database... is not listed, you can download SSDTSetup.exe from https://msdn.microsoft.com/en-us/mt186501 .
  4. Your default Web browser will prompt a download of SSDTSetup.exe
  5. In your Downloads folder, run SSDTSetup
  6. Follow the prompts of the installer

After doing this, just to play it safe, I restarted Visual Studio. This might not be necessary. I then did the following in Visual Studio.

  1. In Visual Studio, if you do not already have a folder named App_Data, in the Solution Explorer panel, right-click the name of your site and select Add > New Folder . Name the new folder App_Data.
  2. With the App_Data folder highlighted, press Ctrl + Shift + A (or right-click and select Add > New Item)
  3. In the Add New Item pop-up box, select Visual Basic or C# > Data > SQL Server Database . Click Add .

The error should not appear, and in Solution Explorer should now be a file named database1.mdf.

Just do this. On Visual Studio, go to Tools > Options > Database Tools > Data Connections. Here clear the "SQL Server Instance Name (blank for default)" option and write SQLEXPRESS

The error message is quite clear. You need to have either LocalDB or SQL Server Express installed and running on the local computer, and you apparently don't.

Do as the error message instructs, go to the link provided in that error message, select Microsoft SQL Server Data Tools, and install the latest version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM