How to add LocalDB to Visual Studio 2015 Community#39;s SQL Server Object Explorer?(如何将 LocalDB 添加到 Visual Studio 2015 社区的 SQL Server 对象资源管理器?)
问题描述
问题
我不明白如何让 LocalDB 显示在 SQL Server 对象资源管理器中.在某些虚拟机上,它会自动显示,在其他一些虚拟机上,它不会.尽管如此,在谷歌搜索了几个小时后,我还是不明白.
现状
- 我有一个干净的虚拟机
- 我安装了 Visual Studio 2015 Community(所有默认设置)
- 我让一个控制台应用程序运行(实体框架 6,代码优先,控制台应用程序),它在另一个虚拟机上运行并自动创建一个数据库,然后显示在 SQL Server 对象资源管理器中;但这次不是
错误说:
System.Data.SqlClient.SqlException (0x80131904):建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接.(提供程序:SQL 网络接口,错误:52 - 无法找到本地数据库运行时安装.验证 SQL Server Express 是否已正确安装并且本地数据库运行时功能已启用.)--->System.ComponentModel.Win32Exception (0x80004005): 系统找不到指定的文件因此,在此 VM 上,不会创建任何数据库,也不会在 SQL Server 对象资源管理器的 SQL Server
节点中显示任何内容.
我想知道的
- Visual Studio 2015 社区附带 LocalDB;所以一切都应该开箱即用,但事实并非如此,我不知道为什么
- LocalDB 数据库只是一对文件(*.mdf 和 *.ldf)
- 我已经看到在
C:UsersAppDataLocalMicrosoftMicrosoft SQL Server Local DBInstancesMSSQLLocalDB
的默认数据库位置创建的文件;但是在这个虚拟机上,没有这样的文件夹 App.config
每次都是这样的(当我在 Visual Studio 中安装 Entity Framework 6 NuGet 包管理器时,它是自动创建的):
App.config
<预><代码><配置><configSections>
其他随机评论
- 之前,对于 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 对象资源管理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将 LocalDB 添加到 Visual Studio 2015 社区的 SQL Server 对象资源管理器?
基础教程推荐
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01