score:0

public class Chapter
{
    public int Id { get; set; }

    ...
}

public class PhysicsChapter : Chapter
{
    ...
}

public class MathsChapter : Chapter
{
    ...
}

public class SchoolGrade
{
    public int Id { get; set; }

    public List<Chapter> Chapters { get; set; }

    ...
}

public class SchoolGradeContext : DbContext
{
    public SchoolGradeContext() : base("SchoolGradeContext")
    {
    }

    public DbSet<SchoolGrade> SchoolGrades { get; set; }

    public DbSet<Chapter> Chapters { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Chapter>().Map<PhysicsChapter>(m => m.Requires("ChapterTypeId").HasValue(1));
        modelBuilder.Entity<Chapter>().Map<MathsChapter>(m => m.Requires("ChapterTypeId").HasValue(2));
    }
}

score:0

public class Chapter
 {
     public string ChapterName {get; set;}
     public string ChapterContent {get; set;}

     [ForeignKey("SchoolGrade")]
     public Guid SchoolGradeID {get; set;}
 }

Related Query

More Query from same tag