Click here to Skip to main content
15,793,547 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys,

I am working with the Entity Framework 5 at the moment and try to build my first DB application. I do have 2 tables:

DataSet1 and DataSet2.

DataSet1 has a reference to DataSet2 and the code that gets build by the EntityFramework works in a way, that if I read DataSet1 from the DB, DataSet2 is already included as an object in DataSet1, not just the key (ID), but the whole object. Which is basically good, because I like to have the direct access to the object. So I do not need to get back to the DB to search for the right object.

While I do have access to DataSet1 all the time, it seems that I loose DataSet2 from time to time. I cannot say when or why, but sometimes I do have access to DataSet2 via the DataSet1 object and sometimes I get the Exception:

'(m.projectset).Client' threw an exception of type 'System.ObjectDisposedException'

Is there a rule, why I lose connection or how to avoid this?
how to deal with such relations, if one object contains another object instead of just the key of it?

Jameel VM 10-Oct-14 9:00am    
where is the code you have tried?

1 solution

Solved it. Eager loading was the solution!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900