Visual Studio 2012 Ultimate新依赖关系图错误

8

在使用Visual Studio 2012 Ultimate工作时,每次创建新的依赖关系图表都会出现以下错误:

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.

我的解决方案已经成功构建,我的连接字符串如下:

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

这里的问题是什么?
2个回答

19

你的问题很可能是由于本地数据库实例出现了问题:

%localappdata%\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0

我遇到了同样的问题,因为当我安装VS12时,我的计算机不在一个域中,最近我将其加入到一个域中,并且我的用户帐户没有访问SQL数据库的权限。
为了解决这个问题,我运行了:

sqllocaldb stop "v11.0" -k
sqllocaldb delete "v11.0"
sqllocaldb create "v11.0" 
sqllocaldb start "v11.0"

然后我重新启动了 VS 2012,现在我的本地DB可用,并且依赖图已创建。


我电脑上没有安装本地DB,是否有办法可以使用SQL Server 2008 R2代替本地DB。我的连接字符串已经设置正确,但仍然出现错误。 - Amir Jalali
相当肯定它必须使用LocalDB,我相信这是VS的先决条件安装。 - Todd Carter
这个答案也解决了我在Visual Studio 2013 Ultimate上遇到的同样问题。卸载/重新安装LocalDB没有起作用,但是这些命令让它工作了。 - stricq
第三个命令对我失败了,错误信息如下:创建本地数据库实例“v11.0”失败,因为出现以下错误:指定的 LocalDB 版本在此计算机上不可用。 我成功使用 v12.0 创建了一个本地数据库,但不知道在哪里更改连接字符串。 - Vitor Canova
我需要重新安装v11.0版本。可以在这里找到。 - Vitor Canova
显示剩余2条评论

0

在尝试了建议的解决方案后,我仍然遇到了错误。 我不得不以管理员身份运行Visual Studio,这样问题就解决了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接