I get this error:
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
when i try to update the database with the Update-Database
command in the Package Manager Console.
How can I write the lines to the output window in visual studio?
I tried:
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;
}
But that didn't work. Any other suggestions on how to debug this?