C# 使用实体框架获取更改属性时出错

C# 使用实体框架获取更改属性时出错,c#,entity-framework,change-tracking,C#,Entity Framework,Change Tracking,我使用的是实体框架,我需要知道表的哪个字段被修改了,所以我编写了这段代码 IEnumerable<ObjectStateEntry> changes = this.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Deleted | EntityState.Modified).ToList(); foreach (ObjectStateEntry stateEntryEnt

我使用的是实体框架,我需要知道表的哪个字段被修改了,所以我编写了这段代码

IEnumerable<ObjectStateEntry> changes = this.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Deleted | EntityState.Modified).ToList();
        foreach (ObjectStateEntry stateEntryEntity in changes)
        {
            if (stateEntryEntity.Entity != null)
            {
                var stateEntry = this.ObjectStateManager.GetObjectStateEntry(entry.Entity);
                IEnumerable<string> modifiedProperties = stateEntry.GetModifiedProperties(); 
            }
        }
IEnumerable changes=this.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Deleted | EntityState.Modified).ToList();
foreach(更改中的ObjectStateEntry StatentryEntity)
{
if(statentryentity.Entity!=null)
{
var stateEntry=this.ObjectStateManager.GetObjectStateEntry(entry.Entity);
IEnumerable modifiedProperties=stateEntry.GetModifiedProperties();
}
}
问题是,我得到的不是修改后的字段,而是修改后对象的所有字段

你知道我为什么有这种奇怪的行为吗


谢谢

代码中的
这是什么?