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

Answers

  • Hello,

    >>Where can I check these errors ?

    EntityValidationErrors is a collection which represents the entities which couldn't be validated

    successfully, and the inner collection ValidationErrors per entity is a list of errors on property level.

    These validation messages are usually helpful enough to find the source of the problem. You can use try catch block and DbEntityValidationException to see the detail information:

    try
    
    {
    
        context.SaveChanges();
    
    }
    
    catch (DbEntityValidationException e)
    
    {
    
        foreach (var eve in e.EntityValidationErrors)
    
        {
    
            Console.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)
    
            {
    
                Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
    
                    ve.PropertyName, ve.ErrorMessage);
    
            }
    
        }
    
        throw;
    
    }
    
    Regards.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 22, 2014 8:18 AM
    Moderator