Description
In 5.0 RC1 I get lots of warnings logged like this:
warn: Microsoft.EntityFrameworkCore.Query[20504]
Compiling a query which loads related collections for more than one collection navigation property either via 'Include' or through projection but no 'QuerySplittingBehavior' has been configured. By default EF Core will use 'QuerySplittingBehavior.SingleQuery' which can potentially result in slow query performance. See https://go.microsoft.com/fwlink/?linkid=2134277 for more information. To identify the query that's triggering this warning call .ConfigureWarnings(w => w.Throw(RelationalEventId.MultipleCollectionIncludeWarning))
If I actually follow the help and call ConfigureWarnings(w => w.Throw(RelationalEventId.MultipleCollectionIncludeWarning))
I will get an exception thrown to identify the queries. This is good.
However, some of these identified queries are using AutoMapper ProjectTo
. If I actually try to use AsSplitQuery()
on them I will get another exception.
InvalidOperationException: The query has been configured to use 'QuerySplittingBehavior.SplitQuery' and contains a collection in the 'Select' call, which could not be split into separate query. Please remove 'AsSplitQuery' if applied or add 'AsSingleQuery' to the query.
I believe the warning only should be logged for queries where it is actually possible to use AsSplitQuery()
.