Is this really the expected behavior? I'm using the standard T4 POCO templates (but Repository and UnitOfWork generated via http://geekswithblogs.net/danemorgridge/archive/2010/06/28/entity-framework-repository-amp-unit-of-work-t4-template-on.aspx although the problem seems to be with the POCO fixup)
If I do the following
var UOW = new EFUnitOfWork();
UOW.LazyLoadingEnabled = true;
UOW.ProxyCreationEnabled = true;
var horderRepo = RepositoryHelper.GetHORDERRepository(UOW);
var subrelmRepository = RepositoryHelper.GetSUBRELMRepository(UOW);
var ho = horderRepo.Where(h=>h.RECORD_NUMBER==1).FirstOrDefault();
var somerelm = subrelmRepository.Where(r=>r.RECORD_NUMBER==ho.REALM_KEY+1).FirstOrDefault();
ho.SUBRELM=somerelm;
UOW.Commit();
return View(ho);
each time I change the ho.SUBRELM to a new RELM the expected POCO fixup is called. If that relm is pointed to by 100,000 other HORDERS (which some are) then the fixup seems to walk the lot of them, taking forever (or until memory runs out - whichever is the sooner)
If I turn lazyloading off, this doesn't happen, but should I really expect fixup to back-walk all of the relationships in my database ? Or has something else gone wrong? If so, what?
This is well known problem of using POCO entities generated by T4 template with a lazy loading. You can't avoid it unless you simply modify your RELM to not contain navigation property to all included HORDERS. Other possibilities are modifying T4 to not use fixup collections or writting POCOs by yourselves.
Just conclusion - it is not incorrect behavior of EF. It is an unexpected behavior of code generated by T4 template.