【发布时间】:2013-05-13 04:05:11
【问题描述】:
我收到此错误:
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
当我尝试在包管理器控制台中使用Update-Database 命令更新数据库时。
如何将行写入 Visual Studio 的输出窗口?
我试过了:
try
{
context.SaveChanges();
}
catch (System.Data.Entity.Validation.DbEntityValidationException e)
{
foreach (var eve in e.EntityValidationErrors)
{
System.Diagnostics.Debug.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)
{
System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
ve.PropertyName, ve.ErrorMessage);
}
}
throw;
}
但这没有用。有关如何调试此问题的任何其他建议?
【问题讨论】:
标签: ef-code-first entity-framework-5 nuget-package