I am using EF 7.0.0-rc1-final.
The following statement generates multiple queries on the server. Is this normal or I am missing something ?
Group myGroup = dbContext_
.Set<Group>()
.Include(x => x.GroupRoles)
.ThenInclude(x => x.Role)
.FirstOrDefault(x => x.Name == "Approver");
I see two separate queries executed on the server:
And
It's a standard many-to-many scenario. Why is the first query ?
Thanks
Yes, it’s normal even in one to many scenarios.
EF7 generates multiple queries to avoid returning the same data multiple times.
Here is a great post about EF6 Include to understand why this change was required for EF7: Entity Framework pitfalls, include
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With