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.