After upgrading to 6.1.2.0, we've started experiencing some odd behavior with Navigation Properties. I've been trying to isolate the code that is causing problems or reproduce the bad behavior in a NorthwindDb, but I haven't had much luck.
As I said, I haven't had much problems narrowing it down, but sometimes Navigation Properties will have the Null Entity in them, even though the referenced entity is in the cache. Also, we have all our Navigation Properties set to ReferenceStrategy.NoLoad. So code like this works fine:
const int orderId = 10248;
//I can get the order details out of the EM like this - so I know they are in the cache var details1 = em.OrderDetails.With(QueryStrategy.CacheOnly).Where(od => od.OrderID == orderId).ToList();
//details1 will now have 3 items in it
//Grab the order and then try to get it's details with the navigation property... var order = em.Orders.With(QueryStrategy.CacheOnly).Single(o => o.OrderID == orderId); //order is the correct entity
var details2 = order.OrderDetails.ToList(); //details2 is just an empty list! |
This all worked fine before we upgraded to 6.1.2.0 - in fact, it even worked in an early 6.1.2 build that you gave us (I believe it was 6.1.2.0e.
The way we load data into our entity manager could be part of the problem. We bulk load data through multiple InvokeServerMethodAsync calls that return EntityCacheStates. The problem only seems to happen when the two entities involved (in the case above, that would be Order and OrderDetails) are loaded in two different batches. I'm thinking maybe there is a problem with how the navigation properties get 'fixed up' when RestoreCacheState is called.
I'm still trying to see if I can narrow down the problem further but I wanted to post here in case there is anything that might jump out....or something that maybe I should check.
Thanks,
-Stephen