I wonder if you could help. I get the above error when I call .Include()
. It breaks when I include tblMemberships
.
this.dbContext.Confi
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")