EF Core 1.0 - Include() generates more than one queries

entity-framework-core

Question

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:

Query 1

And

Query 2

It's a standard many-to-many scenario. Why is the first query ?

Thanks

1
11
2/21/2016 1:16:14 PM

Accepted Answer

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

9
8/22/2018 10:12:03 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow