How to add LocalDB to Visual Studio 2015 Community#39;s SQL Server Object Explorer?(如何将 LocalDB 添加到 Visual Studio 2015 社区的 SQL Server 对象资源管理器?)
本文介绍了如何将 LocalDB 添加到 Visual Studio 2015 社区的 SQL Server 对象资源管理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题
我不明白如何让 LocalDB 显示在 SQL Server 对象资源管理器中.在某些虚拟机上,它会自动显示,在其他一些虚拟机上,它不会.尽管如此,在谷歌搜索了几个小时后,我还是不明白.
现状
- 我有一个干净的虚拟机
- 我安装了 Visual Studio 2015 Community(所有默认设置)
- 我让一个控制台应用程序运行(实体框架 6,代码优先,控制台应用程序),它在另一个虚拟机上运行并自动创建一个数据库,然后显示在 SQL Server 对象资源管理器中;但这次不是
错误说:
其他随机评论
之前,对于 SQL Server,需要打开某些端口,但据我所知,LocalDB 在 Visual Studio 启动时作为一个单独的进程按需运行.
我不知道如何调试SQLException
LocalDB 是否未随 Visual Studio 2015 社区一起打包,我是否需要单独安装?
解决方案
我今天在安装 VS2015 Community Edition Update 1 时遇到了同样的问题.
我通过从 VS2015 安装程序安装程序中添加SQL Server Data Tools"解决了这个问题......当我运行安装程序我第一次选择自定义"安装类型而不是默认".我想看看有哪些安装选项可用,但不要选择与已勾选的内容不同的任何内容.我的假设是已经打勾的基本上是默认安装.但它不是.
Problem
I don't understand how to make LocalDB show up in the SQL Server Object Explorer. On some VMs, it shows up automatically, on some other VMs, it doesn't. Still, after googling for hours, I don't get it.
Current situation
I have a clean VM
I installed Visual Studio 2015 Community (all default settings)
I let a console application run (Entity Framework 6, code-first, console application) which worked on another VM and created a database automatically which then showed up in the SQL Server Object Explorer; but not this time
The error says:System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.) ---> System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
So, on this VM, no database gets created and nothing shows up in the SQL Server Object Explorer's SQL Server node.
What I think to know
Visual Studio 2015 Community comes with LocalDB; so everything should just work out of the box, but it doesn't, and I don't know why
LocalDB databases are just a pair of files (*.mdf and *.ldf)
I've seen the files being created at the default database location at C:Users<username>AppDataLocalMicrosoftMicrosoft SQL Server Local DBInstancesMSSQLLocalDB; but on this VM, there is no such folder
The App.config looked every time like this (and it was automatically created that way when I installed Entity Framework 6 the NuGet Package Manager in Visual Studio):
App.config
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Other random comments
Earlier, with SQL Server, it was necessary to open up certain ports, but LocalDB runs, as I understand it, as a separate process on demand when started by Visual Studio.
I don't know how to debug the SQLException
Does LocalDB not come packaged with Visual Studio 2015 Community and do I need to install it separately?
解决方案 I had the same issue today recently installing VS2015 Community Edition Update 1.
I fixed the problem by just adding the "SQL Server Data Tools" from the VS2015 setup installer... When I ran the installer the first time I selected the "Custom" installation type instead of the "Default". I wanted to see what install options were available but not select anything different than what was already ticked. My assumption was that whatever was already ticked was essentially the default install. But its not.
这篇关于如何将 LocalDB 添加到 Visual Studio 2015 社区的 SQL Server 对象资源管理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!