Reputation: 159
Having an issue where I can not include [RelatedTableTwo] when loading data into my EF 6 DBContext object. I have tried using ThenInclude, but it does not find the tables and errors out. The code is using EntityFrameWorkCore. Here is the code:
'var MainTable = context.MainTable
.Include(i => i.RelatedTableOne)
.ThenInclude(ti => ti.RelatedTableTwo)
.ThenInclude(ti => ti.RelatedTableThree)
.Where(p => p.Id ==id)
.ToList();'
[I believe the issue is Related Table Two has a one-to-many relationship to Related Table One which is not allowing the loading of the data from the Context object.] <- This is not the fact.
Upvotes: 0
Views: 498
Reputation: 159
Found the issue. When I used the "dotnet ef dbcontext scaffold" command it created HashSets. When using the includes, the includes did not recognize Related Table Two. I changed the HashSet variables to generic list collections and now it works.
Upvotes: 1