Visual Studio 2015无法连接到MSSQLLocalDB [英] Visual Studio 2015 cannot connect to MSSQLLocalDB

查看:239
本文介绍了Visual Studio 2015无法连接到MSSQLLocalDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习C#和Entity Framework 6 ...而且它已经比我预期的要糟糕得多。 

我创建了一个简单的新项目,并添加了EF6,同时创建了数据库中包含"更新数据库",我得到: 



>与
>发生了网络相关或特定于实例的错误。建立与SQL Server的连接。找不到服务器或者是b $ b>无法访问。验证实例名称是否正确以及是否为b
> SQL Server配置为允许远程连接。 (提供商:SQL

>网络接口,错误:26 - 错误定位服务器/实例

>指定)



我没有更改任何配置或任何东西,只是创建了一些分类并想要生成数据库,这是默认的连接工厂:&


  &NBSP; < defaultConnectionFactory type =" System.Data.Entity.Infrastructure.LocalDbConnectionFactory,EntityFramework">

  &NBSP; &NBSP; < parameters>

  &NBSP; &NBSP; &NBSP; < parameter value =" MSSQLLocalDB" />

  &NBSP; &NBSP; < / parameters>

  &NBSP; < / defaultConnectionFactory>
$


我甚至通过运行此命令检查实例是否正在运行:`sqllocaldb info`,结果是: 



  &NBSP; MSSQLLocalDB

  &NBSP; ProjectsV13



和此相同: 



  &NBSP; SqlLocalDB.exe启动

  &NBSP; LocalDB实例"MSSQLLocalDB"开始。

解决方案


以  的Visual Studio 2012 &NBSP;我不得不这样输入是:

 <代码风格="保证金:0像素;填充:0像素;边界:0像素;字体大小:13像素;字体家庭:索拉,万络,摩纳哥,"龙力控制台","解放单声道","幻觉记忆三世Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif; white-space:inherit">(localdb)\ v11.0 



或  Visual Studio 2015  更改为:

 (localdb)\ MSSQLLocalDB 



作为服务器名称添加  Microsoft
SQL Server数据
  source in:

  View / Server Explorer /(右键单击)数据连接/添加连接



然后填充数据库名称。我不需要在接受的答案中执行所有其他步骤,尽管它会是如果服务器名称在服务器名称组合框中自动可用,那就太好了。



您还可以使用以下方法浏览计算机上可用的LocalDB数据库名称:

 

查看/ SQL Server对象资源管理器。

http://stackoverflow.com/questions/21563940/how-to-connect-to-localdb- in-visual-studio-server-explorer


Im just starting to learn C# and Entity Framework 6 ... and it's already far worse than i expected. 
I have created a simple new project, and added EF6, while creating to database with "Update-Database", i get: 

> 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: 26 - Error Locating Server/Instance
> Specified)

I Havent changed any config or anything, just created some classed and wanted to generate the database, here is the default connection factory: 

    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="MSSQLLocalDB" />
      </parameters>
    </defaultConnectionFactory>

I even check if the instance is running by running this command: `sqllocaldb info`, which resulted in: 

    MSSQLLocalDB
    ProjectsV13

and same for this: 

    SqlLocalDB.exe start
    LocalDB instance "MSSQLLocalDB" started.

解决方案

In Visual Studio 2012 all I had to do was enter:

(localdb)\v11.0

or Visual Studio 2015 changed to:

(localdb)\MSSQLLocalDB

as the server name when adding a Microsoft SQL Server Data source in:

View/Server Explorer/(Right click) Data Connections/Add Connection

and then the database names were populated. I didn't need to do all the other steps in the accepted answer, although it would be nice if the server name was available automatically in the server name combo box.

You can also browse the LocalDB database names available on your machine using:

View/SQL Server Object Explorer.

http://stackoverflow.com/questions/21563940/how-to-connect-to-localdb-in-visual-studio-server-explorer


这篇关于Visual Studio 2015无法连接到MSSQLLocalDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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