日志中出现Entity Framework修改数据库时的错误:

Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.

从表面看不出来哪里错了,增加以下try...catch代码,捕获异常:

try
{
// 数据库操作
}

catch (DbEntityValidationException ex)
{

}

最终在ex.EntityValidationErrors中找到,是因为增加的数据超出了最大长度限制!

相关文章:

  • 2021-08-24
  • 2021-08-05
  • 2021-10-13
  • 2021-12-31
  • 2022-12-23
猜你喜欢
  • 2021-10-08
  • 2022-02-10
相关资源
相似解决方案