Tuesday, September 16, 2014

Validation failed for one or more entities. See 'EntityValidationErrors' property for more details

try
{
    //...........
    dc.SaveChanges();
}
catch (DbEntityValidationException ex)
{
    foreach (var eve in ex.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);
        }
    }
}
Look for errors in the output window during debugging

No comments:

Post a Comment