Entity framework 实体框架中的多对多关系不';t检索相关集合
我试图首先使用代码在实体框架中映射多对多SQL关系 以下是我的课程: [表(“B3_360; ViewerData”)]Entity framework 实体框架中的多对多关系不';t检索相关集合,entity-framework,orm,ef-code-first,mapping,Entity Framework,Orm,Ef Code First,Mapping,我试图首先使用代码在实体框架中映射多对多SQL关系 以下是我的课程: [表(“B3_360; ViewerData”)] 公共类视图数据:实体 { //……其他财产// //导航属性 公共EntityCollection功能{get;set;} } [表(“B3_特征”)] 公共类特性:实体 { /…其他属性// //导航属性 公共ICollection ViewerData{get;set;} } 创建表[dbo]。[ViewerDataFeatures]( [Feature_Id][in
公共类视图数据:实体
{
//……其他财产//
//导航属性
公共EntityCollection功能{get;set;}
}
[表(“B3_特征”)]
公共类特性:实体
{
/…其他属性//
//导航属性
公共ICollection ViewerData{get;set;}
}
创建表[dbo]。[ViewerDataFeatures](
[Feature_Id][int]NULL
[ViewerData_Id][int]NULL
)
该表中的插入操作与我预期的一样顺利,但是当我想要检索ViewerData实体时,我没有填充Features集合,它是null
我错过什么了吗 为什么将
EntityCollection
和ICollection
混合使用?对于这两个集合,我都会尝试ICollection
。这并不重要,因为EntityCollection
实现ICollection
加载ViewerData
时是否包括功能,比如上下文.ViewerData.include(v=>v.Features).
?
public class ViewerData : Entity
{
//.... Other properties ...//
// The navigation property
public EntityCollection<Feature> Features { get; set; }
//.... Other properties ...//
// The navigation property
public ICollection<ViewerData> ViewerData { get; set; }