Visual Studio代码映射:无法连接到指定的数据库

时间:2022-09-05 20:20:31

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

由于这个错误,我无法在Visual Studio中使用Code Map:

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.

使用以下连接字符串连接数据库时发生异常:数据源=(LocalDB)\v11.0;AttachDbFilename=;初始目录=master;集成安全性=True;登记=False;异步处理=True;MultipleActiveResultSets=True;连接超时=30。

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

检查指定的SQL Server实例是否存在,服务是否正在运行。

I've read this questions with the same problem:

我读过同样的问题:

Code Map not working in VS2012

代码映射在VS2012中不起作用

visual studio 2012 ultimate new dependency graph error

visual studio 2012终极新依赖图错误

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

1)我为VS2012安装了SQL Server数据工具

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

2)我更新了VS,并重新安装了SQL Server组件(在默认的卸载/修改/修复菜单中)

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

3)然后成功地停止和删除本地数据库(如第2个问题):

sqllocaldb stop "v11.0" -k

sqllocaldb停止“v11.0”- k

sqllocaldb delete "v11.0"

sqllocaldb删除“v11.0”

But failed to create one:

但没能创造一个:

sqllocaldb create "v11.0"

sqllocaldb创建“v11.0”

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

由于以下错误,LocalDB实例“v11.0”的创建失败:

The specified LocalDB version is not available on this computer.

指定的LocalDB版本在这台计算机上不可用。

But creating and starting another version succeeded:

但是创建和启动另一个版本成功了:

sqllocaldb create "v12.0"

sqllocaldb创建“v12.0”

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

用12.0.2000.8版本创建的LocalDB实例“v12.0”。

sqllocaldb start "v12.0"

sqllocaldb开始“v12.0”

LocalDB instance "v12.0" started.

LocalDB实例“v12.0”开始。

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

现在我搞不清到底是怎么回事了。在每一步之后,我重新启动VS并尝试使用图表——但没有任何改变。

How to fix the problem?

如何解决这个问题?

2 个解决方案

#1


1  

Have you tried changing your database name? You can use something like (Look at your web.config file)

你试过改变你的数据库名称吗?您可以使用类似(查看您的web。配置文件)

<add name="DefaultConnection" connectionString="Data Source=YourDatasource;Initial Catalog=DatabaseNameAsYouWish;Integrated Security=SSPI" providerName="System.Data.SqlClient" />

If you use sql management studio, you will find the Data Source Connection string while you are conntecting to database. Copy and paste it, then try again. If it works, let me know please.

如果您使用sql management studio,您将在连接到数据库时找到数据源连接字符串。复制粘贴,然后再试一次。如果可以的话,请告诉我。

#2


2  

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

检查自动和命名(或私有)LocalDb实例之间的区别。

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.

v11.0 (SQL Server 2012)所需的支持文件可能不再安装在系统上。v12.0表示SQL Server版本2014。

#1


1  

Have you tried changing your database name? You can use something like (Look at your web.config file)

你试过改变你的数据库名称吗?您可以使用类似(查看您的web。配置文件)

<add name="DefaultConnection" connectionString="Data Source=YourDatasource;Initial Catalog=DatabaseNameAsYouWish;Integrated Security=SSPI" providerName="System.Data.SqlClient" />

If you use sql management studio, you will find the Data Source Connection string while you are conntecting to database. Copy and paste it, then try again. If it works, let me know please.

如果您使用sql management studio,您将在连接到数据库时找到数据源连接字符串。复制粘贴,然后再试一次。如果可以的话,请告诉我。

#2


2  

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

检查自动和命名(或私有)LocalDb实例之间的区别。

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.

v11.0 (SQL Server 2012)所需的支持文件可能不再安装在系统上。v12.0表示SQL Server版本2014。