How to view 'Entity Framework DbEntityValidation Exception was unhandled by user code' errors?

John Avis by | July 23, 2014 | ASP.NET Web Forms ASP.NET MVC Web Development

If you are using Entity Framework and have received this error message and have been frustrated by not being able to see what the actual problem is in Visual Studio then there is a simple solution.
Entity Framework DbEntityValidation Exception was unhandled by user code

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


If you are using Entity Framework and have received this error message and have been frustrated by not being able to see what the actual problem is in Visual Studio then there is a simple solution.

Simply add the following expression to your Watch window:

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

This will give you the information you need to diagnose the problem.

Here's an example of what you will see:

DbEntityValidation Exception watch

Alternately you can press Ctrl+F9 to bring up the QuickWatch dialog and enter the same expression there.

Related Posts

Computers & Internet Web Development Website Hosting

500 Internal Server Error after migrating from IIS 7.5 to IIS 10

by John Avis | November 4, 2019

As support ends for Microsoft Windows Server 2008 I have recently gone through migrating some websites to a new server running Windows Server 2016 and IIS 10 but some of the websites did not work.


Jquery/Javascript Web Development

tagInput: A simple jQuery plugin for tag entry using Bootstrap 4

by John Avis | October 15, 2019

For a website project I needed a way to enter multiple tags. I just wanted something simple that I could easily modify to suit my own needs, so I wrote my own.


ASP.NET Web Forms Web Development

ASP.NET bug with RadioButton GroupName in Repeater

by John Avis | September 1, 2019

I rediscovered a bug in ASP.NET that affects RadioButtons inside repeaters. Here is my solution to the problem.

Comments

Ben Hudelson

by Ben Hudelson | March 15, 2016

Thanks. Saved me some time.

Reply

Leave a Comment

Tags

About me

...random postings about web development and programming, Internet, computers, electronics and automotive topics.

Subscribe

Get the latest posts delivered to your inbox.