How to view 'Entity Framework DbEntityValidation Exception was unhandled by user code' errors?
by johna | 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:
This will give you the information you need to diagnose the problem.
Here's an example of what you will see:
Alternately you can press Ctrl+F9 to bring up the QuickWatch dialog and enter the same expression there.
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:
Alternately you can press Ctrl+F9 to bring up the QuickWatch dialog and enter the same expression there.
Related Posts
Another pointless project - the programmable digital watch
by johna | January 20, 2025
I've come up with yet another pointless project. Would you like a watch that you could program yourself - but not a "smart watch"?
Converting dBase IV programs to run in the browser
by johna | September 13, 2024
Some pointless entertainment trying to get some old dBase programs running in the browser.
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.
Comments
by Ben Hudelson | March 15, 2016
Thanks. Saved me some time.
Reply