The client that you publish from the form will not have entity keys, therefore it cannot be well connected, and you also may not have every client field in the form so that all its fields cannot be set.
I would recommend using the TryUpdateModel method, in your action you will have to get the client from the database again and update it using the form column variables.
public ActionResult MySaveAction(int id, FormCollection form)
{
Customer updateCustomer = _Repository.GetCustomer(id);
TryUpdateModel(updateCustomer, "Customer", form);
_Repository.Save(updateCustomer);
}
You will need to add all your own exception handling and checking, but this is a general idea.
source
share