Witam, mam problem z edycją obiektu "Employee".
public void Edit(int id, Employee employee)
{
var oldEmployee = _context.Employees.SingleOrDefault(x => x.Id == id);
if(employee.Picture == null)
{
employee.Picture = oldEmployee.Picture;
}
employee.DateAdded = oldEmployee.DateAdded;
_context.Employees.Update(employee);
_context.SaveChanges();
}
Błąd: The instance of entity type 'Employee' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.
Nie mam pomysłu jak to obejść.