A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name ''

試著忘記壹切 提交于 2019-12-02 10:01:59

When you write code like this:

db.ParentTable
    .Include("ChildTable")
    .Include("ChildOfChildTable");

You are saying include all entries from ChildTable that are keyed to ParentTable and also include all entries from ChildOfChildTable that are ALSO keyed to ParentTable. Instead you need to tell Entity Framework that ChildOfChildTable is beneath ChildTable in the hierarchy, like this:

db.ParentTable
    .Include("ChildTable.ChildOfChildTable");

So this means your code should be:

this.dbContext.Configuration.LazyLoadingEnabled = false;
List<tblCustomerInfo> customers = this.dbContext.tblCustomerInfoes
                                      .Include("tblUsers.tblMemberships")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!