Prompt data change error on update
In the update event prompted the following error, found on the internet, most of it is a conflict, but only one client in the test at the same time, there should be no conflict issues, and later found that the editor loading ID, and the update submitted when the ID is different, the original is not on the editing interface for ID write bound fields, It should be found that the ID is empty at commit time, and the new ID is generated automatically.
The ID is the primary key, using the automatically generated GUID.
In the editing of the main field is still not missing ah ...
Database operation expected to affect 1 row (s) but actually affected 0 row (s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/? linkid=527962 for information on understanding and handling optimistic concurrency exceptions.
About Modelstate.isvalid
The model's properties are always true if they are not validated, and false if the validation-related attribute is modelstate.isvalid, and modelstate.isvalid is not satisfied.
Modelstate.isvalid will also be false when a parameter attribute type is received that does not match the model definition.
You can use the following code to query for specific errors
if(!modelstate.isvalid) {varmsg =string. Empty; foreach(varValueinchmodelstate.values) {if(value.) Errors.Count >0) { foreach(varErrorinchvalue. Errors) {msg= msg +error. errormessage; }}} Console.WriteLine (msg); returnPage (); }
ASP. NET Core Operational myths