Getting the EntityValidationErrors list in the nearest window

How can I get a list of errors in the immediate window when this happens in VS 2012

Verification failed for one or more objects. For more information, see EntityValidationErrors Property.

there seems to be no easy way to display them without creating some code modifications to cycle through them like this:

foreach (var failure in ex.EntityValidationErrors)
    {
       string validationErrors="";

        foreach (var error in failure.ValidationErrors)
        {
           validationErrors+=error.PropertyName+"  "+error.ErrorMessage;
        }
    }
+5
source share
1 answer
((System.Data.Entity.Validation.DbEntityValidationException)$exception)

in the Monitoring window will give you access to the exception instance. You can check out a collection of errors there.

I keep this available on my watchlist, so I can just update if I encounter this exception.

+20
source

All Articles