This project has moved and is read-only. For the latest updates, please go here.

Relationship issues

Dec 23, 2015 at 9:35 PM
So I'm trying to do something that I would think is fairly straightforward. I have an entity (MasterOrder) that has children (Orders). I am loading the data / relationship in via the CSV loader.

When I attempt to run a MasterOrder through a processing method though, and it attempts to loop through the Orders, there are none there.

Which is weird because as soon as I add a line like
var orders = _db.Orders.ToList();
in before calling the processing method, they ARE there, both in the "orders" variable via debug and in the normal loop where they weren't showing up before.

All fairly normal EF setup on all of this, nothing special.

Any idea why I would be seeing this? Only caveats I have:
  1. The MasterOrder processing method is async and is awaited.
  2. Test method itself is async.
  3. Test runner is NUnit.
  4. On DbContext we have LazyLoadingEnabled set to false
I have a suspicion its that last one, but just wanted to make sure I understood what the issue is.
Jan 9, 2016 at 4:56 AM
Edited Jan 9, 2016 at 4:57 AM
Number 4 is your problem. When you say LazyLoadingEnabled = false, it doesnt mean that it is eager loaded. It means that, do not load (relationships) at all.

There is no way until EF6 to eager load the complete DB. I am also facing a similar problem where each of my test case is lazy loading from CSV and creating a lag in the test cases.