【发布时间】:2011-12-08 17:43:23
【问题描述】:
我有一个必须实现 IList<T> (background info here) 的 ComplexType。
不幸的是,Entity Framework 抱怨该接口所需的索引属性
[NotMapped]
public T this[int index]
(注意它用NotMapped 数据注解修饰)。
我在运行时收到 DbUpdateException 内部异常
不支持索引属性。
如果我注释掉该类实现 IList<T> 并注释掉索引属性,则该类的实例将按预期保留。
有没有办法让复杂类型实现 IList<T> 以被实体框架代码优先持久化?
【问题讨论】:
-
我将标签更改为 EFv4.1,因为 EFv4.2 只是 4.1 的错误修复,不需要单独的标签。
标签: entity-framework entity-framework-4.1 ef-code-first