This code is giving an error when trying to update the database
Error:An object with a key that
matches the key of the supplied object
could not be found in the
ObjectStateManager. Verify that the
key values of the supplied object
match the key values of the object to
which changes must be applied.
public void UpdateAccuralSettings(SystemTolerance updatedObject)
{
_source.SystemTolerances.ApplyCurrentValues(updatedObject);
_source.SaveChanges();
}
ApplyCurrentValuesworks only if entity is first loaded from the database (if you don’t use the same context you used for loading it before it is most probably not):If you want to just save your current data without reloading entity use: