public void TestParallelQueriesShouldCacheData() { var serviceProvider = TestsBase.GetServiceProvider(); var debugInfo1 = new EFCacheDebugInfo(); TestsBase.ExecuteInParallel(() => { using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope()) { using (var context = serviceScope.ServiceProvider.GetRequiredService <SampleContext>()) { var firstProductIncludeTags = context.Products .Include(x => x.TagProducts).ThenInclude(x => x.Tag) .Select(x => new { Name = x.ProductName, Tag = x.TagProducts.Select(y => y.Tag) }) .OrderBy(x => x.Name) .Cacheable(debugInfo1, serviceProvider) .FirstOrDefault(); Assert.IsNotNull(firstProductIncludeTags); } } }); Assert.AreEqual(true, debugInfo1.IsCacheHit); }