UnitOfWorkinator.EFCore
1.0.3
dotnet add package UnitOfWorkinator.EFCore --version 1.0.3
NuGet\Install-Package UnitOfWorkinator.EFCore -Version 1.0.3
<PackageReference Include="UnitOfWorkinator.EFCore" Version="1.0.3" />
<PackageVersion Include="UnitOfWorkinator.EFCore" Version="1.0.3" />
<PackageReference Include="UnitOfWorkinator.EFCore" />
paket add UnitOfWorkinator.EFCore --version 1.0.3
#r "nuget: UnitOfWorkinator.EFCore, 1.0.3"
#:package UnitOfWorkinator.EFCore@1.0.3
#addin nuget:?package=UnitOfWorkinator.EFCore&version=1.0.3
#tool nuget:?package=UnitOfWorkinator.EFCore&version=1.0.3
<p align="center"> <img src="assets/logo.png" alt="UnitOfWorkinator logo" width="200"/> </p>
<p align="center"><b>Repositories on autopilot. Unit of Work without the paperwork.</b></p>
What is UnitOfWorkinator?
UnitOfWorkinator is a .NET library that takes the pain out of configuring and managing repositories using the Unit of Work pattern.
Just define your repositories, and it will:
- Discover and register them automatically
- Inject the correct DbContext
- Keep everything clean, testable, and free of boilerplate
Designed for developers who like clean architecture and hate repetitive setup.
Installation
You can install UnitOfWorkinator via NuGet:
Install-Package UnitOfWorkinator
Example Usage
Defining Repositories
With UnitOfWorkinator, you only need to define your repositories. Here's how you can do it:
public interface IProductRepository : IProductRepository
{
// Your custom repository methods
}
public interface IOrderRepository : IOrderRepository
{
// Your custom repository methods
}
Implementing repositories
For a multi-context application you must inject DbContext base class.
For a single-context application you can inject the concrete DbContext implementation (not mandatory).
public interface ProductRepository(DbContext context) : BaseRepository(context), IProductRepository
{
// Implements the repository method
}
public interface IOrderRepository(DbContext context) : BaseRepository(context), IOrderRepository
{
// Implements the repository method
}
Configuring UnitOfWorkinator
Now, configure UnitOfWorkinator to automatically discover and register your repositories:
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// Configure your DbContext
services.AddDbContext<MyDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
// Automatically register repositories and de UnitOfWork
services.AddUnitOfWorkinator<MyDbContext>();
}
}
Using Repositories
Once everything is set up, you can inject the UnitOfWork and use your repositories anywhere in your application:
public class MyService(IUnitOfWork unitOfWork)
{
private readonly IProductRepository _productRepository = unitOfWork.Repository<IProductRepository>();
private readonly IOrderRepository _orderRepository = unitOfWork.Repository<IOrderRepository>();
public void DoSomething()
{
// Use your repositories here
var products = _productRepository.GetAll();
var orders = _orderRepository.GetAll();
}
public async Task DoSomethingMore(int id)
{
// Use your repositories here
_productRepository.Delete(id);
// Use to save the changes in the unit of work
await unitOfWork.SaveChangesAsync();
}
}
Enjoy!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 9.0.4)
- Microsoft.Extensions.DependencyInjection (>= 9.0.4)
- UnitOfWorkinator.Abstractions (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.