我使用 SQL Server 创建了一个简单的 .NET 7.0 应用程序,如果我使用默认的“localdb”,甚至在将其更改为“网络服务器”之后,我会收到以下错误:
证书链是由不受信任的机构颁发的。
我的连接字符串是:
mysqlserver.com;Initial Catalog=db_database;User Id=db_admin;Password=pass123;Persist Security Info=True;Encrypt=true;TrustServerCertificate=yes
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
PS:通过上面的连接字符串,我可以搭建数据库。
为什么我在搭建脚手架时得到的证书不受信任?
我正在运行 EF Tools Scaffold-DbContext 命令并收到以下错误:
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.)
这是我发出的命令:
Scaffold-DbContext "Server=SQL.mysite.com;Initial Catalog=db_data;User Id=db_admin;Password=pass123;Persist Security Info=True;Encrypt=true/yes" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Context "MyDataDbContext" -DataAnnotations -Force
您能帮我了解如何解决这个问题吗?