Let's say you have a book. A book can have an author, an editor, a proof reader, or several other credits. Which credits are available should be dynamic (someone might not want to have the "proof reader" credit, or want to add something not available "out of the box"). Each credit can have one or many people.
I would normally model it like this in the database
Book Credit Person
---- ------ ------
ID ID ID
Title Name Name
BookCreditPersonRelation
--------------------------
FK_BookID
FK_CreditID
FK_PersonID
And for code-first EFCore I would write it like this:
public class Book {
public int ID { get; set; }
public string Title { get; set; }
public ICollection<BookCreditPersonRelation> BookCreditPersonRelations { get; set; }
}
public class Credit {
public int ID { get; set; }
public string Name { get; set; }
public ICollection<BookCreditPersonRelation> BookCreditPersonRelations { get; set; }
}
public class Person {
public int ID { get; set; }
public string Name { get; set; }
public ICollection<BookCreditPersonRelation> BookCreditPersonRelations { get; set; }
}
public class BookCreditPersonRelation {
public Book Book { get; set;
public Credit Credit { get; set; }
public Person { get; set; }
}
Does this look "right" to you? Is there a "Better Way" (TM)