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

Source: Internet
Author: User

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.