首页 > 其他 > 详细

Validation failed for one or more entities.

时间:2015-05-20 14:36:05      阅读:223      评论:0      收藏:0      [点我收藏+]
 验证失败后用DbEntityValidationException 查找出错的字段

try { // Your code... // Could also be before try if you know the exception occurs in SaveChanges int effect = await _unitOfWorkAsync.SaveChangesAsync(); } catch (System.Data.Entity.Validation.DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; }

 

Validation failed for one or more entities.

原文:http://www.cnblogs.com/xiaoyu369/p/4517050.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!