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;");