升級到 Entity Framework Core 7 後第一個遇到的錯誤:
原因是 Microsoft.Data.SqlClient 4.0 以後會驗證 SQL Server 憑證,最正確的方式是加上憑證來解決這個問題。
或是在連接字串後面加上 TrustServerCertificate=true; 讓其信任伺服器憑證也可以暫時解決,不會再拋出錯誤。
參考資料:
Microsoft.Learn - Login-phase errors
Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - 此憑證鏈結是由不受信任的授權單位發出的。)
---> System.ComponentModel.Win32Exception (0x80090325): 此憑證鏈結是由不受信任的授權單位發出的。
原因是 Microsoft.Data.SqlClient 4.0 以後會驗證 SQL Server 憑證,最正確的方式是加上憑證來解決這個問題。
或是在連接字串後面加上 TrustServerCertificate=true; 讓其信任伺服器憑證也可以暫時解決,不會再拋出錯誤。
"DefaultConnection": "Server=localhost;Database=ruyut;User=ruyut;Password=ruyut;TrustServerCertificate=true;"
參考資料:
Microsoft.Learn - Login-phase errors
留言
張貼留言
如果有任何問題、建議、想說的話或文章題目推薦,都歡迎留言或來信: a@ruyut.com