更新DB时出错:SQL网络接口,错误:26 - 指定服务器/实例时出错 [英] Error when updating DB: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified

查看:151
本文介绍了更新DB时出错:SQL网络接口,错误:26 - 指定服务器/实例时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用EF6,并对我的模型做了一些修改。
现在突然我通过nuget命令更新数据库时遇到以下错误: Update-Database

I'm using EF6 and have been making a few changes to my model. Now all the sudden I get the following error when trying to update my database through the nuget command Update-Database:



建立与SQL Server的连接时发生网络相关或实例特定的错误。找不到服务器或
无法访问。验证实例名称是否正确,并且
SQL Server配置为允许远程连接。 (提供程序:SQL
网络接口,错误:26 - 查找服务器/实例错误
指定)

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)

在我的连接设置(或通常的 web.config )中没有更改任何内容,但这里是我的连接字符串:

I did not change anything in my connection settings (or web.config in general) but here's my connection string:

  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\LM.DataAccess.mdf;Initial Catalog=LM.DataAccess;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

服务器资源管理器 - > 数据连接我可以访问数据库没有任何问题。

In Server Explorer -> Data Connections I can access the database without any problems.

这里可能是什么问题?我尝试通过 SQL Server对象资源管理器删除数据库,但我仍然得到错误。

What could be the issue here? I tried deleting the database through the SQL Server Object Explorer but I still get the error.

仍然需要帮助的人。
如果有人可以帮助我,我真的很感激 - 我尝试了一切我可以!

Still need help people. Would really appreciate if someone could help me out - I've tried everything I could!

推荐答案

您的迁移项目不是StartUp项目,这意味着您需要在StartUp项目中设置connectionstring,使其正常工作。

Thats caused when your migrations project is not the StartUp project, which means you'll need to set the connectionstring in the StartUp project for it to work correctly.

希望它有帮助。
最好的问候。

Hope it helps. Best Regards.

这篇关于更新DB时出错:SQL网络接口,错误:26 - 指定服务器/实例时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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