当前位置:Gxlcms >
数据库问题 >
How to handle the DbEntityValidationException in C#
How to handle the DbEntityValidationException in C#
时间:2021-07-01 10:21:17
帮助过:2人阅读
{
db.SaveChanges();
}
catch (DbEntityValidationException dbEx)
{
foreach (
var validationErrors
in dbEx.EntityValidationErrors)
{
foreach (
var validationError
in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}",
validationError.PropertyName,
validationError.ErrorMessage);
}
}
}
Using debug tools, set breakpoints, then you will see the detail error message during the foreach loop.
How to handle the DbEntityValidationException in C#
标签: