2017-02-10 111 views
1

我的應用程序庫XXX.Data連接字符串更新數據庫失敗,錯誤0x80131904(服務器未找到)

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

。但是,當命令update-database在PMC啓動時,會顯示錯誤:

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
  1. 我不得不卸載包含EF xxx.web項目,但它沒有連接字符串。

  2. 步驟1之後,它的工作用於下面的命令與2個參數:

    update-database -ConnectionStringName "XXX" -ProjectName "XXXX.Data" 
    
相關問題