Monday, 11 June 2012

See 'EntityValidationErrors' property for more details

This morning I was doing a db.SaveChanges() and getting the error:
See 'EntityValidationErrors' property for more details
I'd seen this umpteen times before and always resolved it quickly without having to to look at the EntityValidationErrors property. This morning however I couldn't work our where it was failing, and what field I needed to pay attention to, so I really did need to look into this property. After a bit of googling and good old Stack Overflow, I found this to be the easiest way. Simply put the following into your watch list:
((System.Data.Entity.Validation.DbEntityValidationException)$exception).EntityValidationErrors

2 comments:

Comments are moderated, so you'll have to wait a little bit before they appear!