原始代码是:
modelBuilder.Entity<OriginalClass>().Map<OtherClass>(x => x.Requires("Field1").HasValue("Value1"));
它无法编译,我似乎找不到等效的代码。
我在这里找到了答案
https://learn.microsoft.com/en-us/ef/core/modeling/relational/inheritance
我的核心代码将是这样的
modelBuilder.Entity<OriginalClass>((.HasDiscriminator<string>("Field1"(.HasValue<OtherClass>("Value1"(.HasValue<OtherClass2>("Value2"(;
以下是将其转换为实体工人的方法
modelBuilder.Entity<OtherClass>().
HasNotNullable(x => x.Field1).
HasDefaultOnEmpty(x=> x.Field1, "the field is empty"));
阅读属性部分https://github.com/AlenToma/EntityWorker.Core/blob/master/Documentation/Attributes.md