How to store one entity class in another in specific relation between tables?

167 Views Asked by At

I have these relations in my data base: enter image description here

I need all authors related to my book stored in book entity class? I was trying to resolve this by using entityset but I can't use it because there is no primary key in BookAuthors table!

Any kind of help will be great! =)

1

There are 1 best solutions below

0
On BEST ANSWER

LINQ-to-SQL requires a primary key in order for it to materialize entities. And since neither Books nor Authors entities know anything about each other, I think your only option is to add a PK to BookAuthors as Pleun mentioned.

This question is very similar to yours, but note the PK on the Order_Detail table: Problem with Linq2Sql Many-to-Many relationship & Inserting new objects.