views:

12

answers:

1

The setup: EntityFramework POCO with proxies (+LazyLoading)

Component and Part classes both implement IDataErrorInfo (if this is necessary). The following code throws exception:

// Context is a singleton here
Context.LoadProperty<Part>(
    partEntity, 
    (e) => e.ChildComponents, 
    MergeOption.OverwriteChanges);

The ambiguous property is ChildComponents as I can tell yet there is no other property with the same name, its only definition is:

public virtual ICollection<Component> ChildComponents { get; set; }

This is overridden in EF proxy and changed into something like

public virtual EntityCollection<Component> ChildComponents { get; set; }

Yet this issue just appeared and I cannot understand why now as there were no real changes.

A: 

I have investigated this matter and turns out that .NET compiles indexers (e.g. from IDataErrorInfo) into Item, therefore introducing some kind of ambiguousness in a class that is called Item and any classes that have such a property. That causes problems in EF. This problem is buried in my code more deeply than I thought and not all info is present in initial post (mainly the fact that Component class has an Item property).

Jefim