繁体   English   中英

更新数据库失败,错误 0x80131904(未找到服务器)

[英]update-database fails with error 0x80131904 (server not found)

我的应用程序有连接字符串

  <connectionStrings>
    <add name="XXX" connectionString="Data Source=(LocalDb)\v14.0;Initial Catalog=XXX;Integrated Security=SSPI; MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
  </connectionStrings>

在库 XXX.Data 中。 但是在PMC中启动update-database命令时,显示错误:

Target database is: 'XXX' (DataSource: .\SQLEXPRESS, Provider: System.Data.SqlClient, Origin: Convention).
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: 26 - Error Locating Server/Instance Specified)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)

它尝试连接到.\\SQLEXPRESS而不是(LocalDb)\\v14.0;Initial Catalog=XXX 为什么?

我在任何 dll 文件中都没有任何其他连接字符串。

更新 1:我尝试使用其他连接字符串,但也失败了:

<connectionStrings>
    <add name="XXX" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=XXX;Integrated Security=SSPI; MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
  </connectionStrings>
  1. 我不得不卸载包含 EF 的 xxx.web 项目,但它没有连接字符串。

  2. 在第 1 步之后,它适用于以下带有 2 个参数的命令:

     update-database -ConnectionStringName "XXX" -ProjectName "XXXX.Data"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM