I have a ComplexType
that must implement IList<T>
(background info here).
Unfortunately, Entity Framework complains about the indexed property required of that interface
[NotMapped]
public T this[int index]
(Note it's decorated with the NotMapped
data annotation).
I get a DbUpdateException
at runtime with the inner exception
Indexed properties are not supported.
If I comment out that the class implements IList<T>
and comment out the indexed property, instances of the class persist as expected.
Is there some way for a complex type to implement IList<T>
to be persisted by Entity Framework Code First?
Entity framework doesn't support open generic entities and I believe the same is true for complex types. The only way is to define specific type derived from closed generic type as you shown in your linked question.
Also there is some well known bug that mapped class must not have indexer.