Koto.Infrastructure.EFCore
0.4.0
dotnet add package Koto.Infrastructure.EFCore --version 0.4.0
NuGet\Install-Package Koto.Infrastructure.EFCore -Version 0.4.0
<PackageReference Include="Koto.Infrastructure.EFCore" Version="0.4.0" />
<PackageVersion Include="Koto.Infrastructure.EFCore" Version="0.4.0" />
<PackageReference Include="Koto.Infrastructure.EFCore" />
paket add Koto.Infrastructure.EFCore --version 0.4.0
#r "nuget: Koto.Infrastructure.EFCore, 0.4.0"
#:package Koto.Infrastructure.EFCore@0.4.0
#addin nuget:?package=Koto.Infrastructure.EFCore&version=0.4.0
#tool nuget:?package=Koto.Infrastructure.EFCore&version=0.4.0
Koto.Infrastructure.EFCore
EF Core 10 integration for the Koto DDD suite: generic repository, strongly-typed ID converters, specification pattern, and Wolverine outbox wiring.
Install
dotnet add package Koto.Infrastructure.EFCore
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL # or your preferred provider
What's included
| Type | Purpose |
|---|---|
KotoDbContext |
Abstract DbContext; auto-applies StronglyTypedIdConvention; clears domain events after save |
Repository<TAgg, TId> |
Generic IRepository implementation backed by EF Core |
StronglyTypedIdValueConverter<TId, TRaw> |
EF Core ValueConverter for StronglyTypedId<T> properties |
StronglyTypedIdConvention |
Auto-applies converters to all strongly-typed ID properties |
ISpecification<T> / Specification<T> |
Encapsulates query criteria, includes, and ordering |
SpecificationEvaluator |
Applies a specification to an IQueryable<T> |
AddKotoEFCore<TContext>() |
Registers the DbContext via Wolverine's EF Core integration |
Usage
1 — Define your DbContext
public class AppDbContext : KotoDbContext
{
public AppDbContext(DbContextOptions options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
}
}
StronglyTypedIdConvention is applied automatically — no manual HasConversion calls needed.
2 — Register
// Program.cs
builder.Services.AddKotoEFCore<AppDbContext>(opts =>
opts.UseNpgsql(builder.Configuration.GetConnectionString("Db")));
// Wolverine setup — durable outbox (обязательно для доставки событий)
builder.Host.UseWolverine(opts =>
{
// Хендлеры вне entry assembly нужно включить в discovery явно:
opts.Discovery.IncludeAssembly(typeof(SomeHandler).Assembly);
// Durable outbox: конверты хранятся в Postgres сервиса
opts.PersistMessagesWithPostgresql(connectionString); // WolverineFx.Postgresql
opts.Policies.UseDurableOutboxOnAllSendingEndpoints();
opts.UseEntityFrameworkCoreTransactions();
// Для сохранений ВНУТРИ Wolverine-хендлеров (консюмеры):
opts.PublishDomainEventsFromEntityFrameworkCore<IHasDomainEvents, IDomainEvent>(
e => e.DomainEvents);
});
Domain events from plain code (HTTP endpoints)
PublishDomainEventsFromEntityFrameworkCore is a codegen policy that only runs inside
Wolverine handlers. For saves from ordinary code (FastEndpoints → ICommandHandler),
AddKotoEFCore registers EfCoreUnitOfWork<TContext> as the default IUnitOfWork
(TryAddScoped — your own registration wins): on CommitAsync it collects uncommitted
domain events from tracked aggregates and publishes them through Wolverine's EF Core outbox
in the same transaction as your entity changes:
public async Task<Result<OrderId>> HandleAsync(PlaceOrderCommand cmd, CancellationToken ct)
{
var order = Order.Place(...); // AddDomainEvent(...) inside
_orders.Add(order.Value);
await _unitOfWork.CommitAsync(ct); // entities + envelopes in one transaction → handler
return order.Value.Id;
}
3 — Use a repository
public class OrderRepository : Repository<Order, OrderId>
{
public OrderRepository(AppDbContext ctx) : base(ctx) { }
}
Or rely on the registered IRepository<Order, OrderId> directly.
4 — Specifications
public class ActiveOrdersSpec : Specification<Order>
{
public ActiveOrdersSpec(CustomerId customerId)
{
AddCriteria(o => o.CustomerId == customerId && !o.IsCancelled);
AddInclude(o => o.Items);
ApplyOrderBy(o => o.PlacedAt);
}
}
// In a repository or query handler:
var query = SpecificationEvaluator.GetQuery(_context.Set<Order>(), new ActiveOrdersSpec(customerId));
var orders = await query.ToListAsync(ct);
Pagination
var page = await context.Orders
.Where(o => o.CustomerId == customerId)
.OrderByDescending(o => o.CreatedAt)
.ToPagedListAsync(page: 1, pageSize: 20, ct);
Запрос должен быть упорядочен — иначе порядок страниц не определён.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Koto.Application (>= 0.4.0)
- Koto.Domain (>= 0.4.0)
- Microsoft.EntityFrameworkCore (>= 10.0.10)
- WolverineFx (>= 5.39.0)
- WolverineFx.EntityFrameworkCore (>= 5.39.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.4.0 | 92 | 7/21/2026 |
| 0.3.0-preview.15 | 50 | 7/21/2026 |
| 0.3.0-preview.14 | 51 | 7/21/2026 |
| 0.3.0-preview.13 | 48 | 7/21/2026 |
| 0.3.0-preview.12 | 45 | 7/21/2026 |
| 0.3.0-preview.11 | 55 | 7/21/2026 |
| 0.3.0-preview.10 | 52 | 7/21/2026 |
| 0.3.0-preview.9 | 49 | 7/21/2026 |
| 0.3.0-preview.8 | 46 | 7/21/2026 |
| 0.3.0-preview.7 | 45 | 7/21/2026 |
| 0.3.0-preview.6 | 53 | 7/20/2026 |
| 0.3.0-preview.5 | 47 | 7/19/2026 |
| 0.3.0-preview.4 | 53 | 7/19/2026 |
| 0.3.0-preview.3 | 60 | 7/11/2026 |
| 0.3.0-preview.2 | 52 | 7/11/2026 |
| 0.3.0-preview.1 | 54 | 7/3/2026 |
| 0.2.0-preview.1 | 67 | 6/28/2026 |
| 0.1.0-preview.5 | 63 | 5/13/2026 |
| 0.1.0-preview.4 | 62 | 5/13/2026 |
| 0.1.0-preview.3 | 63 | 5/13/2026 |