[ASP .NET MVC] 資料庫連接異常

昨天花了些時間重灌我的電腦,Visual Studio 的環境都設定完畢後

再次開啟 ASP .Net MVC 專案,發現資料庫沒有正確連接!!

在 Pcakage Manager Console 下了 'update-database',出現 0x80131904 的錯誤訊息...

PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
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)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
...
...
...     
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-1,State:0,Class:20
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)   

Server Explorer 頁面更新無效:

搜尋了相關的關鍵字,都沒有找到我要的答案。

赫然想到開啟專案時有出現一個被我忽略的警告訊息:

接著就嘗試下載並安裝 SQLEXPR_x64_ENU,這安裝過程完全是我沒有印象的

完全沒有手動安裝 SQL 的印象...待安裝完畢後。

重開 Visual Studio,再次下了 update-database。

恢!復!正!常!

 

犯蠢了...這玩意之前到底何時自動被安裝的阿...XD