EF Core 2.0中的一个实体2表

bub*_*ubi 6 c# entity-framework entity-framework-core

使用EF Core 2.0是否可以在2个表中映射一个实体?

EF6中与此类似(两个配置相同,它们只是示例)。

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.ApplyConfiguration(delegate(EntityMappingConfiguration<Student> studentConfig)
        {
            studentConfig.Properties(p => new { p.Id, p.StudentName });
            studentConfig.ToTable("StudentInfo");
        });

        Action<EntityMappingConfiguration<Student>> studentMapping = m =>
        {
            m.Properties(p => new { p.Id, p.Height, p.Weight, p.Photo, p.DateOfBirth });
            m.ToTable("StudentInfoDetail");
        };
        modelBuilder.Entity<Student>().Map(studentMapping);

    }
Run Code Online (Sandbox Code Playgroud)

Iva*_*oev 5

EF Core 2.0添加了表拆分拥有的类型(替换EF6 复杂类型),但是您所要求的- 实体拆分仍然不受支持。

他们的GitHib存储库中有一个开放的功能请求Relational:实体拆分支持#620,但我看不到任何具体的计划/时间表,以及何时最终实现。他们最有可能添加TPH继承支持,但这只是我的猜测。