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

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

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

Web Development

How to set up a debugging using the Turnkey Linux LAMP stack and VS Code

by johna | December 19, 2023
The second part in my guide to setting up a website and database using the Turnkey Linux LAMP stack.

Website Hosting Web Development

How to set up a website and database using the Turnkey Linux LAMP stack

by johna | November 18, 2023
If you need to host your own website for the purposes of web development, Turnkey Linux LAMP Stack is an easy to install all-in-one solution that you can set up on a spare computer or a VM (Virtual Machine).

Web Development

Intermittent "Unable to read data from the transport connection: net_io_connectionclosed" errors

by johna | May 6, 2020
If you are having intermittent problems sending email in .NET using System.Net.Mail consider switching libraries.

Comments

Ben Hudelson

by Ben Hudelson | March 15, 2016

Thanks. Saved me some time.

Reply

Leave a Comment

About

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

I recommend ASPnix for web hosting and Crazy Domains for domain registration.

Subscribe

Get the latest posts delivered to your inbox.