Validation failed for one or more entities. See ‘entityvalidationerrors’ solution
Validation failed for one or more entities. See ‘ EntityValidationErrors’ property for moredetails. Unfortunately, there is no further information about
Workaround on how to view entityvalidationerrors details |
In EF programming, we sometimes encounter such an error:
However, follow his prompt “see ‘entityvalidationerrors’ property for more details.” to check in the exception, you can only see
You can’t see the specific reason why the attribute fails to pass the verification. Maybe many people encounter this situation.
Here we introduce an exception class, so that we can easily know which field has a problem.
That is system.data.entity.validation.dbentityvalidationexception. I believe the code knows how to write it. The simplest is
try { // write database } catch (DbEntityValidationException dbEx) { }
We can see it in dbex
So we can see Entityvalidationerrors details of all validation errors.