views:

64

answers:

1

Hello all,

I have a simple application using ADO.NET EntityFramework using a many-to-many relationship between two tables (with the use of a mapping table), let's say Books and Authors. I do have the foreign keys correctly associated between the three tables, I can add two Authors for the same Book and the data is written correctly in the database.

However, after rebuilding the application/running it again, all the associations are lost (all Books have no Authors), even though the relations still exist in the database. I am using the built-in asp.net server from visual studio 2008.

Does anybody have a clue about what's going on?

+2  A: 

I am guessing that your problem is that when you read a book from the database you do not see any authors.

Entity Framework uses lazy load, so it will not load related items unless they are specifically loaded using "Load" or "Include".

http://msdn.microsoft.com/en-us/library/bb896249.aspx

Shiraz Bhaiji
Thank you very much, it works
Tudor Olariu