EntityFrameworkCore.Parallel
7.0.1
dotnet add package EntityFrameworkCore.Parallel --version 7.0.1
NuGet\Install-Package EntityFrameworkCore.Parallel -Version 7.0.1
<PackageReference Include="EntityFrameworkCore.Parallel" Version="7.0.1" />
<PackageVersion Include="EntityFrameworkCore.Parallel" Version="7.0.1" />
<PackageReference Include="EntityFrameworkCore.Parallel" />
paket add EntityFrameworkCore.Parallel --version 7.0.1
#r "nuget: EntityFrameworkCore.Parallel, 7.0.1"
#:package EntityFrameworkCore.Parallel@7.0.1
#addin nuget:?package=EntityFrameworkCore.Parallel&version=7.0.1
#tool nuget:?package=EntityFrameworkCore.Parallel&version=7.0.1
EntityFrameworkCore.Parallel
This extension to Entity Framework Core adds a Set<TContext, TEntity>() method to IDbContextFactory<TContext>.
For easy use it also adds a Parallel() method to IDbContextFactory<TContext> and a Set<TEntity>() method to IDbContextFactory<DbContext>.
This allows you to easily execute multiple queries in parallel without the need to write complex code, or a lot of using blocks or statements.
You can stick to all your known methods from IQueryable<TEntity>.
As the context is disposed after your query is executed, all results will obviously not be tracked and disconnected from any DbContext.
How to use
In your Program.cs, add a DbContextFactory. If you want a pooled one, or not is up to you.
builder.Services.AddPooledDbContextFactory<OrderContext>(options => options.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=OrderTest"));
In your business class, inject an IDbContextFactory<TContext> and use it like this
var ordersFromDb = await _factory.Parallel().Set<Order>().Where(o => o.Id > 3).ToListAsync(cancellationToken);
Or like this
var ordersFromDb = await _factory.Set<MyContext, Order>().Where(o => o.Id > 3).ToListAsync(cancellationToken);
Migration from Entity Framework Core 5 to 6
Since Entity Framework Core 6, IDbContextFactory<TContext> is no longer covariant (TContext is not marked with the out keyword).
Because of that, the following code does no longer work.
var ordersFromDb = await _factory.Set<Order>().Where(o => o.Id > 3).ToListAsync();
See the How to use section for two possibilities that you can use instead. If you want some background information, have a look at https://github.com/dotnet/efcore/issues/26630
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Microsoft.EntityFrameworkCore (>= 11.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EntityFrameworkCore.Parallel:
| Package | Downloads |
|---|---|
|
RESTworld.Business
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.0.1 | 85 | 11/15/2026 |
| 6.0.7 | 918 | 9/10/2026 |
| 6.0.6 | 407 | 8/16/2026 |
| 6.0.5 | 488 | 7/23/2026 |
| 6.0.4 | 16,435 | 3/12/2026 |
| 6.0.3 | 249 | 3/10/2026 |
| 6.0.2 | 515 | 2/10/2026 |
| 6.0.1 | 479 | 1/18/2026 |
| 6.0.0 | 1,002 | 11/11/2025 |
| 5.0.4 | 364 | 11/9/2025 |
| 5.0.3 | 604 | 9/16/2025 |
| 5.0.2 | 493 | 6/19/2025 |
| 5.0.1 | 720 | 1/28/2025 |
| 5.0.0 | 554 | 11/19/2024 |
| 4.1.1 | 11,254 | 10/11/2024 |
| 4.1.0 | 3,828 | 9/20/2024 |
| 4.0.5 | 1,233 | 7/10/2024 |
| 4.0.4 | 500 | 6/4/2024 |
| 4.0.3 | 321 | 5/24/2024 |
| 4.0.2 | 1,219 | 4/19/2024 |