Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore
0.5.0
See the version list below for details.
dotnet add package Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore --version 0.5.0
NuGet\Install-Package Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore -Version 0.5.0
<PackageReference Include="Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore" Version="0.5.0" />
<PackageVersion Include="Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore" Version="0.5.0" />
<PackageReference Include="Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore" />
paket add Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore --version 0.5.0
#r "nuget: Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore, 0.5.0"
#:package Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore@0.5.0
#addin nuget:?package=Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore&version=0.5.0
#tool nuget:?package=Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore&version=0.5.0
Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore
Integración EF Core para Cayaqui.MPS.BuildingBlocks. API fiel al MPS.SharedKernel
original (PostgreSQL: Outbox usa FOR UPDATE SKIP LOCKED).
Contenido
| Área | Tipos |
|---|---|
| Outbox | OutboxMessage (EventId/EventType/retry/permanent-fail), IOutboxStore/IOutboxPurgeable, EfOutboxStore<TDbContext> (FOR UPDATE SKIP LOCKED, IAsyncDisposable), OutboxMessageConfiguration (snake_case + jsonb + índices), OutboxRedispatchHostedService, OutboxPurgeHostedService, OutboxHealthCheck |
| Interceptors | AuditSaveChangesInterceptor (sella CreatedBy/UpdatedBy), DomainEventDispatchInterceptor (persiste eventos al outbox en la misma transacción) |
| CQRS Blazor-safe | ScopedQueryHandler<TQuery,TResponse,TDbContext>, ScopedCommandHandler<...> (ctor IServiceScopeFactory, ExecuteAsync(query, db, sp, ct) → Result<T>, DbContext efímero vía IDbContextFactory) |
| DI | AddDomainEventDispatcher(), AddOutboxRedispatchService(IConfiguration), AddModuleOutbox<TDbContext>(moduleName), AddDomainEventHandlersFromAssembly(asm) |
Setup (host)
builder.Services.AddDomainEventDispatcher();
builder.Services.AddOutboxRedispatchService(builder.Configuration); // redispatch + purge + health
builder.Services.AddScoped<ICurrentUserService, MyCurrentUserService>();
Por módulo
services.AddDbContextFactory<FinanceDbContext>((sp, o) =>
o.UseNpgsql(cs).AddInterceptors(
sp.GetRequiredService<AuditSaveChangesInterceptor>(),
sp.GetRequiredService<DomainEventDispatchInterceptor>()));
services.AddModuleOutbox<FinanceDbContext>("Finance");
services.AddDomainEventHandlersFromAssembly(typeof(SomeFinanceHandler).Assembly);
// FinanceDbContext.OnModelCreating
b.ApplyConfiguration(new OutboxMessageConfiguration());
CQRS
public sealed class ListProjectsHandler(IServiceScopeFactory sf)
: ScopedQueryHandler<ListProjectsQuery, ListProjectsResponse, FinanceDbContext>(sf)
{
protected override async Task<Result<ListProjectsResponse>> ExecuteAsync(
ListProjectsQuery q, FinanceDbContext db, IServiceProvider sp, CancellationToken ct)
{
var rows = await db.Projects.AsNoTracking().ToListAsync(ct);
return new ListProjectsResponse(rows);
}
}
appsettings (opcional): Outbox:Redispatch, Outbox:Purge, Outbox:HealthCheck.
| 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
- Cayaqui.MPS.Abstractions (>= 0.2.0)
- Cayaqui.MPS.Abstractions.Validation (>= 0.1.0)
- Cayaqui.MPS.BuildingBlocks (>= 0.4.0)
- Cayaqui.MPS.Cqrs (>= 0.1.0)
- Microsoft.EntityFrameworkCore (>= 10.0.8)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.8)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
- Scrutor (>= 7.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.
0.5.0 — BREAKING: public namespace MPS.BuildingBlocks.EntityFrameworkCore.* (folder-matched, ya NO MPS.SharedKernel.*). CQRS: TransactionHandlerDecorator (frontera UoW, execution-strategy para Azure SQL, rollback en excepción y en Result de fallo, NO despacha — el outbox interceptor lo hace), AddMpsCqrs<TDbContext> (pipeline de decorators logging→validation→transaction), AddMpsPersistence (audit+domain-event+UTC interceptors), UtcDateTimeInterceptor. Outbox provider-agnóstico (IOutboxDialect: Postgres FOR UPDATE SKIP LOCKED + SqlServer UPDLOCK/READPAST en ReadPending y Purge). 0.4.0 — namespace MPS.SharedKernel.* (shim). 0.3.0/0.2.0 — Outbox rico (OutboxMessage con EventId/EventType/retry/permanent-fail, EfOutboxStore con FOR UPDATE SKIP LOCKED + IAsyncDisposable, OutboxRedispatchHostedService con backoff + deserialización por type name, OutboxPurgeHostedService, OutboxHealthCheck multi-store). DomainEventDispatchInterceptor persiste eventos al outbox en la misma transacción. ScopedQueryHandler/ScopedCommandHandler (ctor IServiceScopeFactory, ExecuteAsync(query,db,sp,ct) → Result<T>). DI: AddDomainEventDispatcher, AddOutboxRedispatchService(IConfiguration), AddModuleOutbox<T>(moduleName), AddDomainEventHandlersFromAssembly. 0.1.0 — initial simplified release.