Microsoft Visual Studio 2022
Asp.net core mvc
DataBase first
用Scaffold-DbContext生成model時出錯:
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 - The certificate chain was issued by an authority that is not trusted.
改字符串連接:
加(Encrypt=True;TrustServerCertificate=True;)即可:
Scaffold-DbContext "Data Source=DBServer;Initial Catalog=DB1;User ID=sa;Password=1234;Encrypt=True;TrustServerCertificate=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models