如何将LocalDB添加到Visual Studio 2015社区的SQL Server对象资源管理器? [英] How to add LocalDB to Visual Studio 2015 Community's SQL Server Object Explorer?

查看:249
本文介绍了如何将LocalDB添加到Visual Studio 2015社区的SQL Server对象资源管理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白如何在SQL Server对象资源管理器中显示LocalDB.在某些VM上,它会自动显示,而在其他VM上,它不会自动显示.不过,在谷歌搜索了几个小时之后,我还是听不懂.

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.

  1. 我有一个干净的VM
  2. 我安装了Visual Studio 2015社区(所有默认设置)
  3. 我让一个控制台应用程序运行(实体框架6,代码优先,控制台应用程序),该应用程序在另一个VM上工作并自动创建一个数据库,然后将其显示在SQL Server对象资源管理器中;但这次不是

错误提示:

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

因此,在此VM上,没有创建任何数据库,并且SQL Server Object Explorer的SQL Server节点中未显示任何内容.

So, on this VM, no database gets created and nothing shows up in the SQL Server Object Explorer's SQL Server node.

  • Visual Studio 2015社区随LocalDB一起提供;所以一切都应该开箱即用,但不能,而且我也不知道为什么
  • LocalDB数据库只是一对文件(* .mdf和* .ldf)
  • 我已经看到在C:\Users\<username>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB的默认数据库位置创建的文件;但是在此VM上没有这样的文件夹
  • App.config每次看起来都是这样(它是我在Visual Studio中安装Entity Framework 6 NuGet程序包管理器时自动创建的):
  • 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>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB; 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):
<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>

其他随机评论

  • 以前,对于SQL Server,有必要打开某些端口,但是据我了解,LocalDB作为Visual Studio启动时按需的独立过程运行.
  • 我不知道如何调试SQLException
  • LocalDB是否不与Visual Studio 2015社区一起打包,我需要单独安装它吗?
  • 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?
    • 推荐答案

      我最近在安装VS2015 Community Edition Update 1时遇到了同样的问题.

      I had the same issue today recently installing VS2015 Community Edition Update 1.

      我通过从 VS2015安装程序安装程序中添加" SQL Server数据工具 "来解决了该问题.我第一次选择自定义"安装类型而不是默认"安装程序.我想看看有哪些可用的安装选项,但没有选择与已勾选的选项不同的任何选项.我的假设是,任何已打勾的内容本质上都是默认安装.但事实并非如此.

      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对象资源管理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆