Currently I am updating the scalar properties of the candidate object like so:
public Candidate EditCandidate(Candidate candidateToEdit)
{
_entities.Candidates.Attach(new Candidate { ID = candidateToEdit.ID });
_entities.Candidates.ApplyCurrentValues(candidateToEdit);
//update candidate.contact here somehow
_entities.SaveChanges();
return candidateToEdit;
}
This only updates the Candidate scalars, since that's what ApplyCurrentValues does. I also need to update the candidate.contact object as well, currently it seems like the only option is to get the current candidate in the database via the candidateToEdit ID, grab the contact ID and updated it that way, but I'm not sure what the "best" way to do this is. candidateToEdit.contact has the values but not the ID since it doesn't get bound in my view. Do I change to the contact context and do that exactly the same way I updated the candidate?
Update: Solution
Based on Dan's answer below.
_entities.Candidates.Attach(candidateToEdit);
_entities.ObjectStateManager.ChangeObjectState(candidateToEdit, EntityState.Modified);
_entities.ObjectStateManager.ChangeObjectState(candidateToEdit.contact, EntityState.Modified);
_entities.SaveChanges();