Reputation: 2079
I have three tables Author, Book and AuthorBook. AuthorBook table only contains two foreign keys pointing to Author and Book tables to achieve many to many relation between Author and Book table.
When I generated models from database, the Author and Book models are created without any association among them. I was expecting "Books" under Author model and "Authors" under Book model. Am I missing anything here or this is the way it works? Here is my table Diagram
And here is my model diagram
Upvotes: 2
Views: 1380
Reputation: 156
is the relation in ur database defined between Book BookAuthor and Author BookAuthor ? --> How do I create a foreign key in SQL Server?
Upvotes: 0
Reputation: 2079
The table BookAuthor was not included by Entity Framework because it did not have a primary key. I fixed this issue by defining a primary key (on authorid and bookid) on the table.
Upvotes: 3