mapping multiple tables to a single entity class in entity framework

You can use Entity Splitting to achieve this if you have the same primary key in both tables.

  modelBuilder.Entity<TestResult>()
    .Map(m =>
      {
        m.Properties(t => new { t.Name, t.Text, t.Units /*other props*/ });
        m.ToTable("Result");
      })
    .Map(m =>
      {
        m.Properties(t => new { t.Status, t.Analysis /*other props*/});
        m.ToTable("Test");
      });

Here’s a useful article

Leave a Comment