Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code Map: Unable to connect to the specified database

I can't use Code Map in Visual Studio due to this error:

Unable to connect to the specified database.

An exception occurred attempting to connect to a database using the following connection string: Data Source=(LocalDB)\v11.0;AttachDbFilename=;Initial Catalog=master;Integrated Security=True;Enlist=False;Asynchronous Processing=True;MultipleActiveResultSets=True;Connect Timeout=30.

Check that the specified SQL Server instance exists and the service is running.

I've read this questions with the same problem:

Code Map not working in VS2012

visual studio 2012 ultimate new dependency graph error

1) I've installed SQL Server Data Tools for VS2012

2) I've updated VS, and re-installed SQL Server component (in a default uninstall/modify/repair menu)

3) Then I successfully stopped and deleted local database (like in 2nd question):

sqllocaldb stop "v11.0" -k

sqllocaldb delete "v11.0"

But failed to create one:

sqllocaldb create "v11.0"

Creation of LocalDB instance "v11.0" failed because of the following error:

The specified LocalDB version is not available on this computer.

But creating and starting another version succeeded:

sqllocaldb create "v12.0"

LocalDB instance "v12.0" created with version 12.0.2000.8.

sqllocaldb start "v12.0"

LocalDB instance "v12.0" started.

Now I'm confused what is actually wrong. After each step I restarted VS and tried to use diagrams - but nothing changed.

How to fix the problem?

like image 597
astef Avatar asked Apr 18 '14 13:04

astef


People also ask

How does Visual Studio connect to database code?

Connect to your database In Visual Studio Code, press Ctrl+Shift+P (or F1) to open the Command Palette. Select MS SQL:Connect and choose Enter. Select Create Connection Profile. Follow the prompts to specify the new profile's connection properties.

How does Visual Studio Connect to local SQL database?

To connect to a database instance In Visual Studio, make sure that SQL Server Object Explorer is open. If it is not, click the View menu and select SQL Server Object Explorer. Right-click the SQL Server node in SQL Server Object Explorer and select Add SQL Server.


2 Answers

This worked for me:

Delete, Create, Start localDB instance used by CodeMap:

%localappdata%\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB

Using these commands:

sqllocaldb stop "MSSQLLocalDB" -k
sqllocaldb delete "MSSQLLocalDB"
sqllocaldb create "MSSQLLocalDB" 
sqllocaldb start "MSSQLLocalDB"

Then restart VS

like image 50
tesstess Avatar answered Sep 21 '22 14:09

tesstess


Check out the difference between automatic and named (or private) LocalDb instances.

The support files necessary for v11.0 (SQL Server 2012) are probably no longer installed on your system. v12.0 indicates SQL Server version 2014.

like image 38
Joe King Avatar answered Sep 23 '22 14:09

Joe King