Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a list of EntityValidationErrors' in the immediate window

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

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

there doesn't appear to be a simple way of displaying them without creating some code modifications to loop through them like so:

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

        foreach (var error in failure.ValidationErrors)
        {
           validationErrors+=error.PropertyName+"  "+error.ErrorMessage;
        }
    }
like image 532
FutuToad Avatar asked Mar 08 '13 21:03

FutuToad


1 Answers

((System.Data.Entity.Validation.DbEntityValidationException)$exception)

in the Watch window will give you access to the exception instance. You can check out the error collection from there.

I keep that available in my Watch list so I can just refresh if I run into that exception.

like image 121
Chris Avatar answered Oct 16 '22 20:10

Chris