一个或多个实体的验证失败 [英] Validation failed for one or more entities
本文介绍了一个或多个实体的验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
string msg =开始报告运行为:;
msg + =Obligor Registry ID:+ obligorID;
msg + =请求组织注册表ID:+ requestsOrgID;
msg + =请求代理注册表ID+ requestAgentID;
TransactionLog lg = new TransactionLog();
lg.TransactionTypeId = 2;
lg.Message = msg;
context.TransactionLogs.Add(lg);
long referenceNumber = context.SaveChanges();
return referenceNumber;
我收到以下错误:
一个或多个实体的验证失败。有关详细信息,请参阅EntityValidationErrors属性。
解决方案
当您处于 catch {...}
块打开QuickWatch窗口( ctrl + alt + q )并粘贴在那里:
((System.Data.Entity.Validation.DbEntityValidationException)ex).EntityValidationErrors
这将允许您深入到 ValidationErrors
树中。这是我找到的最简单的方法来即时了解这些错误。
I have following code in my asp.net MVC3 application:
string msg = "Beginning report run for: ";
msg += " Obligor Registry ID: " + obligorID;
msg += " Requesting Organization Registry ID:" + requestingOrgID;
msg += " Requesting Agent Registry ID: " + requestingAgentID;
TransactionLog lg = new TransactionLog();
lg.TransactionTypeId = 2;
lg.Message = msg;
context.TransactionLogs.Add(lg);
long referenceNumber = context.SaveChanges();
return referenceNumber;
and I am getting following error:
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
解决方案
While you are in debug mode within the catch {...}
block open up the "QuickWatch" window (ctrl+alt+q) and paste in there:
((System.Data.Entity.Validation.DbEntityValidationException)ex).EntityValidationErrors
This will allow you to drill down into the ValidationErrors
tree. It's the easiest way I've found to get instant insight into these errors.
这篇关于一个或多个实体的验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文