Linq System.Collections.Generic.IEnumerable

Linq System.Collections.Generic.IEnumerable,linq,linq-to-sql,frameworks,entity-framework-4,linq-to-entities,Linq,Linq To Sql,Frameworks,Entity Framework 4,Linq To Entities,尝试使用entityframework查询我的数据库时,出现以下错误: “System.Collections.Generic.IEnumerable1[[TASK.Warehouses.Domain.NoteProducts.NoteProduct,TASK.Warehouses.Domain,Version=1.0.0,Culture=neutral,PublicKeyToken=null]]”类型的导航属性不是“System.Collections.Generic.ICollection1

尝试使用entityframework查询我的数据库时,出现以下错误: “System.Collections.Generic.IEnumerable
1[[TASK.Warehouses.Domain.NoteProducts.NoteProduct,TASK.Warehouses.Domain,Version=1.0.0,Culture=neutral,PublicKeyToken=null]]”类型的导航属性不是“System.Collections.Generic.ICollection
1[T]”的单个实现。
问题可能是什么,我如何解决它

您编写了具有IEnumerable导航属性的代码优先类


实体框架要求您的导航属性的类型为
ICollection

您编写的代码第一个类具有
IEnumerable
导航属性


实体框架要求您的导航属性的类型为
ICollection

听起来您有许多名为“TASK.Warehouses.Domain.NoteProducts.NoteProduct,TASK.Warehouses.Domain”的类。如果是这种情况,您将CLR与OO冲突混淆。

听起来您有许多名为TASK.Warehouses.Domain.NoteProducts.NoteProduct,TASK.Warehouses.Domain]。如果是这种情况,您将CLR与违反OO相混淆

♦: 有什么区别?为什么它应该与ICollection一起工作而不是与IEnumerable一起工作?我有一个只使用IEnumerable的项目,它工作得非常好。你能解释一下吗?♦: 有什么区别?为什么它应该与ICollection一起工作而不是与IEnumerable一起工作?我有一个只使用IEnumerable的项目,它工作得非常好。你能解释一下吗?不;这些是CLR通用类型名;这些是CLR通用类型名。