Entity Framework 迁移:无法将 属性 转换为 NotMapped 运行时 getter

Entity Framework migrations: can't convert a property to a NotMapped runtime getter

我在 DAL 中有这个:

public bool MyProp { get; set; }

我的意图是从数据库中删除 属性,并在 运行 时间计算它,所以我将其修改为:

[NotMapped]
public bool MyProp => Smthng > Something.Else;

但是,当我从程序包管理器控制台 运行 Add-Migration -ProjectName Api.My.DAL MyClass.MyProp 时,出现此错误:

The property 'MyProp' is not a declared property on type 'MyClass'. Verify that the property has not been explicitly excluded from the model by using the Ignore method or NotMappedAttribute data annotation. Make sure that it is a valid primitive property.

它要求我确保我没有使用 NotMapped,但我想使用。即使我删除它,错误仍然完全相同。所以我已经不知道要找什么了。

免责声明:我已经在 Google 上搜索过了。很多结果,都是针对与这个完全不同的问题。如果有什么东西在那里,它对我隐藏得很好。

我在 .NET Framework 4.7 项目的 VS 2019 上使用 EF6。

Configuration 文件中进行了额外检查:

Property(smwh => smwh.MyProp).IsRequired();

删除这个就成功了。