I am having a strange problem with the POCO Entity Framework created by the POCO T4 templates. For some objects, their collection properties are created as EntityCollection
, and for others they are created as FixUpCollection
.
I find this with three classes that model the hierarchy of products; ProductGroup
, Platform
and Product
. Each ProductGroup
has a set of Platform
s, and each Platform
has a set of Product
s. All relationships are bidirectional. The collectors and setters are the same for each class, because they are generated by the T4 template, so they all look (for example) as follows:
public virtual ICollection<Platform> Platforms { get { if (_platforms == null) { var newCollection = new FixupCollection<Platform>(); newCollection.CollectionChanged += FixupPlatforms; _platforms = newCollection; } return _platforms; } set { ... } }
The funny thing is that all collections on Product
and Platform
are created as EntityCollection
s, and all collections on ProductGroup
are created as FixUpCollection
s. those. when the code first enters the getter (e.g. Platform.Products
), the _products
field _products
already filled with the EntityCollection
symbol, but when it first enters the getter shown above, _platforms
is null and a FixUpCollection
is created and then populated. Lazy-load works in both cases, it just works differently.
Entities
has the ability to create lazy loading and proxies. Product
, Platform
and CoreProduct
are all dynamic EF proxies in the Entity.DynamicProxies
namespace. I tried very hard to load Platform
and ProductGroup
, which did not matter. I see no difference in how the classes are configured in the model viewer.
It causes me a headache, because one of the collections in the ProductGroup
contains thousands of objects, and I want to request this collection. As far as I know (please correct me if I am wrong). I cannot request FixUpCollection
without loading all the objects into memory, which is not the case with EntityCollection
, because I can use CreateSourceQuery()
. Has anyone seen this behavior before? Are there any settings that I am missing somewhere? Any pointers or help would be greatly appreciated.
source share