升级EF7连接SQL server出错SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - 证书链是由不受信任的颁发机构颁发的。)
今天把项目里的Microsoft.EntityFrameworkCore.SqlServer和Microsoft.EntityFrameworkCore.Tools从6.0.6升级到了最新的7.0.9。一运行程序出错了。
Win32Exception: 证书链是由不受信任的颁发机构颁发的。
Unknown location
SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - 证书链是由不受信任的颁发机构颁发的。)
我用的是.net 6框架,刚开始以为与7.0.9不兼容。后来经过一番搜索原来是数据库连接字符串的问题。
要在连接字符串中加上>>encrypt=false;TrustServerCertificate=True
完整的:data source=192.168.1.100;database=dbx;uid=sa;pwd=abc123;Connect Timeout=200;Max Pool Size = 512;Max Pool Size = 512;encrypt=false;TrustServerCertificate=True