10

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

Error message added for SEO purpose (the question was not findable on search engines)

The XML content in this document cannot be viewed as a graph because it contains unexpected errors. Open the XML Editor to fix these errors and then try re-opening the graph. The actual error found is described below. Unable to connect to the specified database. An exception occurred attempting to connect to a database using the following connection string : Data Source=(LocalDB)\MSSQLLocalDB : Attach DbFilename=;Initial Catalog=master Integrated Security=True;Enlist=False;Asynchronous Processing=True; MultipleActive ResultSets=True Connect Timeout=30. Check that the specified SQL Server instance exists and the service is running. Call Stack : at Microsoft.Repository.SqlInteraction. OpenAndConfigureConnection (SqlConnection connection) Microsoft.Repository.SqlInteraction.<>c__DisplayClass7_0.<UsingConnection>b_0 () at at Microsoft.Repository.SqlInteraction.ExecuteRepositoryAction (Action action) at Microsoft.Repository.SqlInteraction. UsingConnection (SqlConnection sqlConnection, Action`1 act) at Microsoft.Repository.SqlInteraction. UsingMasterConnection (String connectionString, Action`1 act) at Microsoft. Repository. Utilities.GetDbStateAndFileNames (SqlConnectionStringBuilder builder) at Microsoft.Repository. Utilities.GetDatabase State (String connectionString) at Microsoft.VisualStudio. Architecture Tools. Progressive Reveal. PRUtilities. CanQuery (ActionContext context, IProgressionCacheSettings settings) at Microsoft.VisualStudio. ArchitectureTools. Progressive Reveal.GetRepositoryTimestamps Command.Execute (ActionContext context, IGraphStatus status Reporter, IProgressionCacheSettings settings) at Microsoft.VisualStudio. Architecture Tools. ProgressiveReveal. Progressive RevealProvider. GetRepositoryTimestampsHandler (ActionContext context) at Microsoft.VisualStudio. Progression. ActionManager. CallNormalActions (Action action, ActionContext actionContext, Boolean propagateCancellation)
Revious
  • 7,816
  • 31
  • 98
  • 147
user
  • 1,261
  • 2
  • 21
  • 43
  • ...You can also install LocalDB as part of Visual Studio 2017. During Visual Studio installation, select the .NET desktop development workload, which includes SQL Server Express LocalDB. https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-2016-express-localdb?view=sql-server-2017 – smoore4 Jan 25 '19 at 21:12
  • My concern is conflicting installations of SQL Server Express. For my clients, I need to stick with 2012. I'll check to see if your suggestion's an option. – user Jan 26 '19 at 22:36
  • Check out these: https://www.connectionstrings.com/sql-server/ particularly "LocalDB automatic instance with specific data file" Server=(localdb)\v11.0;Integrated Security=true; AttachDbFileName=C:\MyFolder\MyData.mdf; – smoore4 Jan 28 '19 at 12:28
  • master.mdf will be in a place *like* this (slightly different for MSSQL2012: C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA – smoore4 Jan 28 '19 at 16:39
  • @smoore4 - Not seeing this as an issue having to do with connection strings. Following these instructions (https://microsoft.github.io/PartsUnlimited/db/200.6x-Database-SetupSSDTanddbwithVSandVSTS.html), and creating an SSDT project without connection strings, I am still seeing the error issue occurs. Note: In the article's instructions, I target SQL Server 2012 in step 6. – user Feb 04 '19 at 17:35

2 Answers2

10

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
    If this fails, you may need to try SqlLocalDB.exe stop MSSQLLocalDB -k first.
  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.

Piper
  • 851
  • 11
  • 14
0

For me the solution was to delete folder c:\Users\u1\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB\ (stop 'sqlservr.exe' that locks this folder) - and it will be re-created (answer). Looks like this folder (or some file in it) was created by elevated process and neither VS nor sqllocaldb.exe can access it.

GraphWalk
  • 319
  • 3
  • 9