Generate Code Map For Solution - Unable to Connect to the Specified Database

Viewed 778

I am attempting to generate a code map using Visual Studio 2017 Enterprise, but receive the following error:

enter image description here

Note the data source: Data Source=(LocalDB)\MSSQLLocalDB. When I search for MSSQLLocalDB in my solution, nothing comes up. My application does not use SQL Server 2016 (which is what I think the connection string is for). It uses 2012. All my connection strings use (localdb)\v11.0.

Fixes I've attempted / notes:

  • I have tried to view the XML file, but "Open the XML Editor" simply closes the .dgml file in Visual Studio.
  • Changing Visual Studio's data connection (Tools -> Options -> Database Tools -> Data Connections) does not work:

enter image description here

  • Installing SQL server components. Most of the SQL Server components one might find in the Visual Studio Installer are already installed:

enter image description here

  • Visual Studio is up to date: enter image description here

  • I have seen this issue. Not only is that problem for VS2012, the solutions are for web.config. My app is a desktop app, so no web.config. But none of the projects' app.config contain a reference to (LocalDB)\MSSQLLocalDB anyway.

  • Thinking that it might have to do with the latest version of SSDT (15.8.1) no longer supporting SQL Server 2012, I checked the version. It is 15.1.6: enter image description here

Visual Studio is running on Windows 7 Ultimate, SP1, 64-bit.

EDITS

I am using SQL Server express with Local DB.

The issue does not appear to be related to connection strings. Following basic instructions for creating an SSDT project (here), and importing the database (noting that in step 6 I target SQL Server 2012), the issue still remains - no connection strings, and no actual code.

I have also verified that SQL Server 2012 is the only connected server: enter image description here

1 Answers

I had the same issue with VS 2019. My solution was to delete and recreate the database MSSQLLocalDB. The cause was probably that my account didn't have rights to open the DB, maybe because my admin installed Visual Studio with his account.

Here the steps to recreate the DB:

  1. Locate the location of the SQL Server LocalDB utility. For me this is "C:\Program Files\Microsoft SQL Server\130\Tools\Binn\SqlLocalDB.exe".
  2. Open an admin shell in that folder.
  3. SqlLocalDB.exe i shows all database instances.
  4. Delete the DB: SqlLocalDB.exe d MSSQLLocalDB
  5. Recreate the DB: SqlLocalDB.exe c MSSQLLocalDB

Now I can use VS code maps and I can open the DB in the SQL Server Object Explorer in VS.

Related