EF Core 2.0中的一个实体2表

时间:2017-08-20 09:09:48

标签: c# entity-framework entity-framework-core

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

EF6中与此类似的东西(2种配置相同,它们只是样本)。

    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);

    }

1 个答案:

答案 0 :(得分:3)

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

GitHib存储库中有一个开放的功能请求Relational: Entity splitting support #620,但是如果最终实现它,我也看不到任何具体的计划/时间表。最有可能的是,当他们添加TPH继承支持时,这只是我的推测。