A validação falhou para uma ou mais entidades. Veja a propriedade 'EntityValidationErrors' para mais detalhes. Código primeiro
Eu recebo este erro:
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
quando eu tento atualizar o banco de dados com oUpdate-Database
comando no Console do Gerenciador de Pacotes.
Como posso escrever as linhas na janela de saída no visual studio?
Eu tentei:
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;
}
Mas isso não funcionou. Alguma outra sugestão sobre como depurar isso?