Answers for "System.Data.Entity.Validation.DbEntityValidationException: 'Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.' visual basic"

C#
0

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

try
{
    // Your code...
    // Could also be before try if you know the exception occurs in SaveChanges

    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;
}
Posted by: Guest on March-04-2021
1

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

Entity Framework Error Inner
Posted by: Guest on May-19-2021

Code answers related to "System.Data.Entity.Validation.DbEntityValidationException: 'Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.' visual basic"

C# Answers by Framework

Browse Popular Code Answers by Language