0

i have 2 questions about entity framwork many to many, cause i am a new learner:

1. for mvc+EF one to many code first, we can definite 2 class "quesiton" and "option" with Relationship "one to many" for example, and then we adding controller, and chose option "create, delete, edit...", and a mvc program will be done. but for many to many,there will be 3 class, (one class of Relationship),and can we do just like previous methode? cause i did, there wont be any date in "Relationship table", it means that we should do that by adding code ourself? it cant be done aotomatically just like one to many?

2. many to many quesiton, for e.g. i have 2 class with many to many relationship:

public class Author
{
    public int AuthorId { get; set; }
    public string Name { get; set; }
    public ICollection<Book> Books { get; set; }
}

public class Book
{
    public int BookId { get; set; }
    public string Title { get; set; }
    public ICollection<Author> Authors { get; set; }
}

when i create, it will create a table with name "BookAuthors" which contains bookid and authorid, but i want create the "BookAuthors" class myself, cause i will add 2 another properties in this table, so how can i do that? thank you

0 Answers0