after searching and experimenting i still get the error cannot be tracked because another instance even when i have disabled the tracking.....
this is my code
var result = _customerContext.Set<DO_Customer>()
.AsNoTracking()
.Where(x => x.Id == toUpdate.Id).FirstOrDefault();
if (result != null)
{
_customerContext.Entry(result).CurrentValues.SetValues(toUpdate);
_customerContext.Entry(result).State = EntityState.Modified;
foreach (var item in toUpdate.Address)
{
_customerContext.Entry(item).CurrentValues.SetValues(toUpdate);
_customerContext.Entry(result).State = EntityState.Modified;
}
}
await _customerContext.SaveChangesAsync();
Anyone know why AsNoTracking is not working?
i have try everything. Only when i add no tracking in the program.cs it seem to work but thats other code and don't want to disable it fully