2017-02-10 118 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" 
    
相关问题