Asp.net mvc 4 指定的包含路径无效。EntityType“”未声明名为“”的导航属性

Asp.net mvc 4 指定的包含路径无效。EntityType“”未声明名为“”的导航属性,asp.net-mvc-4,entity-framework-5,Asp.net Mvc 4,Entity Framework 5,我想知道你是否能帮忙。当我打电话时,我发现上面的错误。包括。当我加入tblMemberships时,它会中断 抱歉,无法将图像作为我的声誉包含在

我想知道你是否能帮忙。当我打电话时,我发现上面的错误。包括。当我加入tblMemberships时,它会中断

抱歉,无法将图像作为我的声誉包含在<10

我的问题是:

我需要做什么才能获得TBL会员资格? 这是一种推荐的检索数据的方法,还是我应该将其分为两个查询?还是设计完全是垃圾? 我使用的是EF5,ASP.NETMVC4


请告知。谢谢。

当您编写这样的代码时:

db.ParentTable
    .Include("ChildTable")
    .Include("ChildOfChildTable");
db.ParentTable
    .Include("ChildTable.ChildOfChildTable");
您的意思是包括ChildTable中键控到ParentTable的所有条目,也包括ChildOfChildTable中键控到ParentTable的所有条目。相反,您需要告诉实体框架ChildOfChildTable在层次结构中位于ChildTable之下,如下所示:

db.ParentTable
    .Include("ChildTable")
    .Include("ChildOfChildTable");
db.ParentTable
    .Include("ChildTable.ChildOfChildTable");
这意味着您的代码应该是:

this.dbContext.Configuration.LazyLoadingEnabled = false;
List<tblCustomerInfo> customers = this.dbContext.tblCustomerInfoes
                                      .Include("tblUsers.tblMemberships")

当您编写这样的代码时:

db.ParentTable
    .Include("ChildTable")
    .Include("ChildOfChildTable");
db.ParentTable
    .Include("ChildTable.ChildOfChildTable");
您的意思是包括ChildTable中键控到ParentTable的所有条目,也包括ChildOfChildTable中键控到ParentTable的所有条目。相反,您需要告诉实体框架ChildOfChildTable在层次结构中位于ChildTable之下,如下所示:

db.ParentTable
    .Include("ChildTable")
    .Include("ChildOfChildTable");
db.ParentTable
    .Include("ChildTable.ChildOfChildTable");
这意味着您的代码应该是:

this.dbContext.Configuration.LazyLoadingEnabled = false;
List<tblCustomerInfo> customers = this.dbContext.tblCustomerInfoes
                                      .Include("tblUsers.tblMemberships")

也许吧。包括所有人。TBL会员资格是正确的选择吗?@DavidG Ahh。。。。。喊得好!非常感谢。也许吧。包括所有人。TBL会员资格是正确的选择吗?@DavidG Ahh。。。。。喊得好!非常感谢。