When saving data with EF, the following message is displayed: verification of one or more entities fails. For more information, see the "EntityValidationErrors" attribute ., For error details, see
Error message:
Solution:
→ Use try... catch to capture
→ Place a breakpoint on the row where the catch is located, run it, add monitoring to the ex, or press Shift + f9 day off for quick monitoring when running to the ex
→ The error cause is found in the first element -- ErrorMessage attribute in EntityValidationErrors -- ValidationErrors.
PS: you cannot see the specific error when you directly view the exception details. Therefore, you can only use this method.
On the Internet, some users add a more specific class DbEntityValidationException to check the operation. In fact, it is also the specific exception information seen in monitoring, rather than in this, so it is unnecessary.
In this case, the Exception class has to be added with a namespace, but it cannot be remembered. Therefore, it is convenient to directly Exception the general class. This is my opinion.