我在嘗試使用代碼第一次遷移來更新數據庫時一直在努力尋找對以下錯誤的解決方案。代碼優先遷移 - 更新數據庫錯誤 - 網絡相關實例?
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: 50 – Local Database Runtime error occurred. The specified LocalDB instance does not exist.
我設法找到以下內容,我想知道是否有任何其他方法來解決錯誤。
我的回答:
確保您的SQL Server Management Studio中被安裝在PC上,你的SQL Server實例應SQLEXPRESS
V11.0。爲什麼選擇V11.0?因爲用於代碼的Visual Studio本地數據庫首先適用於版本11.0。
轉到SQL Server配置管理器,展開SQL Server網絡配置並雙擊協議SQLEXPRESS
。
確保命名管道和TCP/IP已啓用。
回到你的web應用程序,點擊你的web.config
。您的連接字符串應該是
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-EMS_Events-20151217024735.mdf;Initial Catalog=aspnet-EMS_Events-20151217024735;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
請確保它轉到(LocalDb)\v11.0
。
轉到包管理器控制檯並運行update-database
。
請添加標籤數據庫+版本 –
其V11.0我不能在標籤找到DB版本 –
你應該張貼你的答案*爲*的答案,而不是問題的一部分。 –