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.