Entity Framework 从非抽象 class 继承 table 结构,但创建所有字段

Entity Framework Inherit table structure from non abstract class , but create all the fields

我有几个表是按以下方式声明的

[Table("FileDataQuestions")]
public class QuestionFileData : FileData
{
}

文件数据在 DevExpress.Persistent.BaseImpl.EF

创建的表只有一个 Id 列,但我希望它们使用从 FileData 继承的所有字段创建

我无法将 FileData 抽象化,因为它不是我的代码。文件数据声明为

public class FileData : IFileData, IEmptyCheckable, IObjectSpaceLink, INotifyPropertyChanged

上下文class是

using DevExpress.ExpressApp.Design;
using DevExpress.ExpressApp.EFCore.Updating;
using DevExpress.Persistent.BaseImpl.EF;
using DevExpress.Persistent.BaseImpl.EF.PermissionPolicy;
using Microsoft.EntityFrameworkCore;
namespace Exambuddy2.Module.BusinessObjects
{
    [TypesInfoInitializer(typeof(Exambuddy2ContextInitializer))]
    public class Exambuddy2EFCoreDbContext : DbContext
    {
        public Exambuddy2EFCoreDbContext(DbContextOptions<Exambuddy2EFCoreDbContext> options) : base(options)
        {
        }

        public DbSet<ModuleInfo> ModulesInfo { get; set; }
        public DbSet<ModelDifference> ModelDifferences { get; set; }
        public DbSet<ModelDifferenceAspect> ModelDifferenceAspects { get; set; }
        public DbSet<PermissionPolicyRole> Roles { get; set; }
        public DbSet<PermissionPolicyUser> Users { get; set; }
        public DbSet<FileData> FileData { get; set; }
        public DbSet<ReportDataV2> ReportDataV2 { get; set; }
        public DbSet<Source> Sources { get; set; }
        public DbSet<CourseUnit> CourseUnits { get; set; }
        public DbSet<Topic> Topics { get; set; }
        public DbSet<Question> Questions { get; set; }
        public DbSet<Answer> Answers { get; set; }

        protected override void OnModelCreating(ModelBuilder mb)
        {
            base.OnModelCreating(mb);
            mb.Entity<Topic>().HasOne(b => b.CourseUnit).WithMany(i => i.Topics);
            mb.Entity<Source>().HasOne(b => b.Topic).WithMany(i => i.Sources);
            mb.Entity<Question>().HasOne(b => b.Source).WithMany(i => i.Questions);
            mb.Entity<Answer>().HasOne(b => b.Question).WithMany(i => i.Answers);
        }
    }
}

当我将上下文代码粘贴到问题中时,我发现了我的错误。需要为 FileDataQuestions 创建 DbSet 并为 FileData

移除 DbSet