本文介绍了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"开始。

解决方案

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.

解决方案


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

08-04 00:31
查看更多