簡體   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