1、系统报错:An error occurred while saving the entity changes. See the inner exception for details。

原因: 表中keyId为主键且设置为自增,不需要在此处加入值,去掉KeyId=8 就可以了。如果不设置为自增,则需要加才行。
2、A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - 证书链是由不受信任的颁发机构颁发的。)”

原因:连接字符串的问题。原来是:
optionsBuilder.UseSqlServer("Data Source=DESKTOP-LHCC2G9\\SQLEXPRESS;Initial Catalog=InfoData;Integrated Security=True;");
改为:optionsBuilder.UseSqlServer("Server=DESKTOP-LHCC2G9\\SQLEXPRESS;Database=InfoData;Encrypt=True;Trusted_Connection=True;TrustServerCertificate=True;MultipleActiveResultSets=true;");
文章讨论了两个数据库相关的问题:1)保存实体更改时遇到错误,提示主键KeyId不应赋值,解决方案是设置KeyId为主键并自增;2)服务器连接成功但登录过程出错,原因是SSL证书不受信任,通过修改连接字符串解决了此问题。

4277

被折叠的 条评论
为什么被折叠?



