'Entity Framework Core Include/ThenInclude to get the data
I have tables in my database with the following one-to-many relations:
a -> b
b -> c
b -> d
which are mapped to corresponding navigational properties in the model.
I want to get data from "a" with all related data from "b, c, d".
If I try:
dbcontext.a.Include(x => x.b)
.ThenInclude(x => x.c)
.ThenInclude(x => x.d)
I get an error because this implies a relationship c -> d (instead of b -> d).
Then, if I try:
dbcontext.a.Include(x => x.b)
.ThenInclude(x => x.c)
.Include(x => x.d)
I get an error because this implies a relationship a -> d (instead of b -> d).
I'd appreciate help on how to correctly chain the methods.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
