If Entity Framework throws a validation exception when saving, Visual Studio reports the message,
Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details.
But the in-built ‘View Detail’ dialog doesn’t let you drill into the EntityValidationErrors property.
To view the EntityValidationErrors collection, add the following Watch expression to the Watch window.
((System.Data.Entity.Validation.DbEntityValidationException)$exception).EntityValidationErrors
Which displays a similar to,
The watch expression ‘$exception’ displays any exception thrown in the current context, even if it has not been caught and assigned to a variable.
时间: 2024-12-30 03:03:32