Koto.Infrastructure.EFCore
0.5.0-preview.3
See the version list below for details.
dotnet add package Koto.Infrastructure.EFCore --version 0.5.0-preview.3
NuGet\Install-Package Koto.Infrastructure.EFCore -Version 0.5.0-preview.3
<PackageReference Include="Koto.Infrastructure.EFCore" Version="0.5.0-preview.3" />
<PackageVersion Include="Koto.Infrastructure.EFCore" Version="0.5.0-preview.3" />
<PackageReference Include="Koto.Infrastructure.EFCore" />
paket add Koto.Infrastructure.EFCore --version 0.5.0-preview.3
#r "nuget: Koto.Infrastructure.EFCore, 0.5.0-preview.3"
#:package Koto.Infrastructure.EFCore@0.5.0-preview.3
#addin nuget:?package=Koto.Infrastructure.EFCore&version=0.5.0-preview.3&prerelease
#tool nuget:?package=Koto.Infrastructure.EFCore&version=0.5.0-preview.3&prerelease
Koto.Infrastructure.EFCore
EF Core 10 integration for the Koto DDD suite: generic repository, strongly-typed ID converters, pagination, 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 |
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 (required for events to be delivered)
builder.Host.UseWolverine(opts =>
{
// Handlers outside the entry assembly have to be added to discovery explicitly:
opts.Discovery.IncludeAssembly(typeof(SomeHandler).Assembly);
// Durable outbox: the envelopes are stored in the service's Postgres
opts.PersistMessagesWithPostgresql(connectionString); // WolverineFx.Postgresql
opts.Policies.UseDurableOutboxOnAllSendingEndpoints();
opts.UseEntityFrameworkCoreTransactions();
// For saves INSIDE Wolverine handlers (consumers):
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<AppResult<Guid>> HandleAsync(PlaceOrderCommand command, CancellationToken ct = default)
{
var placed = Order.Place(...); // AddDomainEvent(...) inside
if (placed.IsFailure) return placed.Errors;
_orders.Add(placed.Value);
await _unitOfWork.CommitAsync(ct); // entities + outbox messages in one transaction
return placed.Value.Id.Value;
}
If aggregates raised domain events and no Wolverine outbox (IDbContextOutbox) is registered,
CommitAsync throws instead of saving and dropping the events silently — configure Wolverine
or register your own IUnitOfWork that dispatches them.
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.
Pagination
var page = await context.Orders
.Where(o => o.CustomerId == customerId)
.OrderByDescending(o => o.CreatedAt)
.ToPagedListAsync(page: 1, pageSize: 20, ct);
The query must be ordered (OrderBy), otherwise page boundaries are undefined.
Upgrading from 0.4
0.5 makes EfCoreUnitOfWork.CommitAsync throw when aggregates raised domain events and no Wolverine outbox is registered (0.4 dropped them silently), and removes ISpecification<T> / Specification<T> / SpecificationEvaluator. The step-by-step guide for the whole suite, with before/after code, is
docs/migrations/0.4-to-0.5.md.
| 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.5.0-preview.3)
- Koto.Domain (>= 0.5.0-preview.3)
- 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.5.0-preview.9 | 45 | 11/30/2026 |
| 0.5.0-preview.8 | 55 | 11/30/2026 |
| 0.5.0-preview.7 | 55 | 11/29/2026 |
| 0.5.0-preview.6 | 50 | 11/29/2026 |
| 0.5.0-preview.5 | 59 | 11/29/2026 |
| 0.5.0-preview.4 | 53 | 11/29/2026 |
| 0.5.0-preview.3 | 54 | 11/29/2026 |
| 0.5.0-preview.2 | 55 | 11/29/2026 |
| 0.5.0-preview.1 | 58 | 11/8/2026 |
| 0.4.0 | 167 | 7/21/2026 |
| 0.3.0-preview.15 | 87 | 7/21/2026 |
| 0.3.0-preview.14 | 81 | 7/21/2026 |
| 0.3.0-preview.13 | 80 | 7/21/2026 |
| 0.3.0-preview.12 | 79 | 7/21/2026 |
| 0.3.0-preview.11 | 84 | 7/21/2026 |
| 0.3.0-preview.10 | 86 | 7/21/2026 |
| 0.3.0-preview.9 | 85 | 7/21/2026 |
| 0.3.0-preview.8 | 75 | 7/21/2026 |
| 0.3.0-preview.7 | 80 | 7/21/2026 |
| 0.3.0-preview.6 | 83 | 7/20/2026 |
0.5.0-preview.3 — the compiler keeps a refusal from getting lost (ADR-028): two analyzers ship inside Koto.Domain and reach every project that references a Koto package. KOTO001: a result is discarded (order.Cancel(reason, now); on a line of its own). KOTO002: FirstError is returned as the failure instead of Errors. Both are errors, so existing code may stop building; migration guide: https://github.com/arigatory/Koto/blob/main/docs/migrations/0.4-to-0.5.md