Why some properties value was changed entity state is `UnChanged` in EF Core 2.2.6

c# entity-framework-core

Question

I use EF Core 2.2.6. I come across one strange. I fetched one entity from DB then I changed one property value. I looked ChangeTraker I see entity state is UnChanged. But entity property value was changed. The Most part of stange is that EF create update query. Everythink works fine. I would like to learn why it is working like this. my example is following

 var person = _unitOfWork.PersonRepository.Get(x => x.Id == 20);
 person.RegUserId=5;
 _unitOfWork.Commit();

public TEntity Get(Expression<Func<TEntity, bool>> predicate)
{
  return _dbset.FirstOrDefault(predicate);
}

enter image description here enter image description here

1
0
9/23/2019 1:19:20 PM

Popular Answer

EntityState is recalculated only when ChangeTracker.DetectChanges() is called, typically during SaveChanges().

0
9/23/2019 2:36:05 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow