简体   繁体   中英

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

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);
}

在此处输入图像描述 在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM