About validation failed for one or more entities when you read a database in ASP. NET MVC using the EF's code first method. See ' entityvalidationerrors ' property for more details.

Source: Internet
Author: User

Today in a small site to meet a lot of problems ah, I am still a rookie, understand not much, today a form of the submit button can not be used, have made a few hours alas. But finally, there is a browser has developer options, or I do not know how long I have to continue to troubleshoot, oh, this evening in the data into the database and there is a problem. I'm using the Entity Framework's code first mode to access the database. For data validation I added data annotations to the data model. Of course, at the front desk also introduced some JS so that you can no longer submit data to the server to complete the verification function. We use the Modelstatus.isvalid property when we save user-submitted data in the background. is to determine whether the model state is valid. Modelstatus.isvalid=true If the user fills in data that satisfies the criteria in the data model's data annotations; Conversely Modelstatus.isvalid=false, when this modelstatus.isvalid= True, when the data is valid, we save the data to the database. But today I ran into an exception when I saved the data. Such as.

But I can't find the mistake there. The phrase is one or more entity validation failures, see Entity validation error properties. But this entity verification error how to find it. In fact, we can use the TR and catch in C # to catch this anomaly, and we know exactly where it went wrong. Such as. Because VS2015 is smart, huh. We can see the value when we move the mouse over it. Such as. We can find this error by pressing the hint. Because I'm still a rookie, huh? So there's something wrong, please, the gods point out.

About validation failed for one or more entities when you read a database in ASP. NET MVC using the EF's code first method. See ' entityvalidationerrors ' property for more details.

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.