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

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

ASP.NET Web Forms Bootstrap

More on Bootstrap 4 modals in ASP.NET Web Forms applications using UpdatePanels

by John Avis | April 9, 2019

In this, my third post on this topic, I go over the methods I am using now and the problems I have encountered and overcome.


ASP.NET Web Forms Classic ASP

Custom error pages for ASP.NET Web Forms and Classic ASP in IIS 7 and 8.5

by John Avis | February 20, 2019

I was recently doing some work on a website which has a mixture of older Classic ASP pages and ASP.NET Web Forms pages and ran into problems with custom error pages.


ASP.NET Web Forms

Nicer localised UpdateProgress’ for your ASP.NET pages with multiple UpdatePanels

by John Avis | February 9, 2018

On an ASP.NET Web Forms page with multiple UpdatePanels it’s nice to give the user some feedback when one of the panels is being updated.

Comments

Ben Hudelson

by Ben Hudelson | March 15, 2016

Thanks. Saved me some time.

Reply

Leave a Comment
Tags
ASP.NET Html Forms ASP.NET MVC ASP.NET Web Forms ASP.NET Web Pages Bootstrap C# Classic ASP Cool Websites Databases eBay and PayPal Electrical Repairs General Hardware HTML/CSS Jquery/Javascript Media Center Mobile Phones Responsive Web Design SEO and Social Networking Web Design Web Development Web Security web+db Website Hosting Windows XP Youtube

About me

...mostly about web development and programming, with a little bit of anything else related to the Internet, computers and technology.

Subscribe

Get the latest posts delivered to your inbox.