EF Core 动态忽略列

EF Core dynamically ignoring column

下面我尝试根据实体 class 中设置的属性动态忽略数据库中的列。我不知道该放什么?????我尝试了 prop 但没有用。请帮忙。

            System.Reflection.PropertyInfo[] props = typeof(MyTable).GetProperties();
            foreach (var prop in props)
            {
                object[] attrs = prop.GetCustomAttributes(true);
                foreach (object attr in attrs)
                {
                    DatabaseAttribute dbAttr = attr as DatabaseAttribute;
                    if (dbAttr != null)
                    {
                        string propName = prop.Name;
                        System.Version minVersion = new System.Version(dbAttr.MinVersion);
                        if (databaseVersion < minVersion)
                        {
                            // The database doesn't know about this property, ignore it
                            modelBuilder.Entity<MyTable>().Ignore(d => ?????);
                        }
                    }
                }
            }
    modelBuilder.Entity<MyTable>().Ignore(prop.Name); 

或者您可以动态构建表达式

    modelBuilder.Entity<MyTable>().Ignore(Expression.Property(Expression.Parameter(typeof(MyTable)),prop));