I want to implement Related Pages structure that one page have a list of other pages related to it. But I could't figure out if it is possible. Now I have the structure like this:
public class Page
{
public int ID { get; set; }
public string UrlName { get; set; }
public List<RelatedPages> RelPages1 { get; set; }
}
public class RelatedPages
{
public int ID { get; set; }
public int PageID { get; set; }
public Page Page { get; set; }
// I would like this to be the list of related page IDs
public List<int> RelPagesID { get; set; }
public List<Page> RelPages { get; set; }
}
And here is OnModelCreating method in my DbContext:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<RelatedPages>()
.HasOne(x => x.Page)
.WithMany(x => x.RelPages1)
.HasForeignKey(x => x.PageID);
}