Akay.To.EF
1.0.8
dotnet add package Akay.To.EF --version 1.0.8
NuGet\Install-Package Akay.To.EF -Version 1.0.8
<PackageReference Include="Akay.To.EF" Version="1.0.8" />
<PackageVersion Include="Akay.To.EF" Version="1.0.8" />
<PackageReference Include="Akay.To.EF" />
paket add Akay.To.EF --version 1.0.8
#r "nuget: Akay.To.EF, 1.0.8"
#:package Akay.To.EF@1.0.8
#addin nuget:?package=Akay.To.EF&version=1.0.8
#tool nuget:?package=Akay.To.EF&version=1.0.8
Akay.To.EF
Infraestructura para aplicaciones que usan Entity Framework Core: DbContext base, interceptores, repositorio genérico, Unit of Work, multi-tenancy, soft delete, auditoría, outbox y helpers de consulta. Depende de Akay.To.Core.
¿Para qué sirve?
Para ahorrarte el "plumbing" de EF Core en cada proyecto: un DbContext que ya implementa IUnitOfWork, interceptores que rellenan auditoría y tenants automáticamente, soft delete por interfaz, repositorio genérico y extensiones de consulta listas para usar.
Funcionalidades
Leyenda
- Implementa contrato de Core — el contrato está definido en
Akay.To.Corey este paquete lo implementa.- Consume contratos de Core — las interfaces las implementa tu entidad; este paquete las usa.
- Funcionalidad propia — implementada íntegramente en
Akay.To.EF.
DbContext base
Hereda de BaseDbContext<TContext> (o TenantBaseDbContext<TContext, TTenantId> para multi-tenancy) y obtienes:
IUnitOfWorkya implementado (SaveChangesAsync)CurrentUserIdyCurrentTenantIddesde elIUserContextApplyRuntimeSettings()— command timeout desde settings- Health check automático de conectividad
Soft delete mediante la interfaz ISoftDeletable
Implementa ISoftDeletable (y opcionalmente IUserSoftDeletable para DeletedBy) en la entidad y el SoftDeleteSaveChangesInterceptor convierte los Remove() en borrados lógicos: en vez de DELETE, escribe DeletedAt/DeletedBy. Todas las queries excluyen automáticamente los borrados gracias al global query filter.
Auditoría automática
Implementa IAuditable / IUserAuditable en la entidad y el AuditingSaveChangesInterceptor rellena CreatedAt/CreatedBy al insertar y UpdatedAt/UpdatedBy al modificar.
Multi-tenancy y ownership
Implementa IHasTenant / IHasOwner en la entidad y el TenantOwnershipSaveChangesInterceptor asigna TenantId y OwnerId automáticamente en entidades nuevas. Filtra con WhereTenant(), WhereOwner() y WhereTenantAndOwner().
Eventos de dominio y Outbox
El DomainEventsSaveChangesInterceptor centraliza el ciclo de vida de eventos durante SaveChanges:
- Eventos
IDomainEventnormales: se publican in-process antes/después del commit - Eventos
IOutboxDomainEvent: se serializan aOutboxMessageen la misma transacción que los datos de negocio (consistencia transaccional con el bus) OutboxEventWriterimplementaIOutboxEventWriter(contrato de Core)
Auditoría de cambios (Change Tracking)
Implementa ITrackChanges en la entidad y el ChangeTrackingAuditSaveChangesInterceptor registra en la tabla __ChangeAudit cada Added/Modified/Deleted con OldValue/NewValue en JSON.
Repositorio genérico
Hereda de BaseRepository<TEntity, TId> y obtienes GetByIdAsync, ExistsAsync, Add, Update. Todos los métodos son virtual, así que puedes sobreescribirlos para añadir Include o consultas específicas.
Patrón Specification
Permite implementar fácilmente el patrón specification: define criterios reutilizables con Specification<TEntity> (AddCriteria, AddInclude, AddOrderBy), combínalos con And/Or y aplícalos con ApplySpecification() sobre cualquier IQueryable<T>.
var spec = new ExercisesByDifficulty(Difficulty.Advanced)
.And(Specification<Exercise>.Create(e => e.Status == ExerciseStatus.Pending));
var result = await context.Set<Exercise>().ApplySpecification(spec).ToListAsync(ct);
Extensiones de consulta
ApplyOrdering(sort, asc, sortMap)— ordenación dinámica por diccionarioApplyPaging/ToPagedResponseAsync— paginación sinCOUNTextra (fetchpageSize + 1)SqlHelpers.Contains(term)— LIKE seguro que escapa[,%,_
PersistenceResultExecutor
Envuelve SaveChangesAsync en Result: detecta constraints de BD (índice único, FK) por reflexión y los mapea a errores de negocio conocidos en vez de lanzar DbUpdateException.
Configuración de interceptores
Todos los interceptores se habilitan/deshabilitan desde DbContextInterceptorSettings en appsettings.json o por código.
Registro
services.AddTenantEFContext<AkayDbContext, int>(
settings =>
{
settings.ConnectionString = connectionString;
settings.Interceptors.Auditing = true;
settings.Interceptors.SoftDelete = true;
settings.Interceptors.DomainEvents = true;
settings.Interceptors.ChangeTrackingAudit = true;
},
(sp, ob, s) => ob.UseSqlServer(s.ConnectionString, sql =>
sql.ApplyDbContextSettings(s).EnableRetryOnFailure(3)));
AddTenantEFContext registra automáticamente: IUnitOfWork, IPersistenceResultExecutor, ICurrentTenant, los interceptores habilitados y el health check del DbContext.
Documentación
Consulta docs/ para guías detalladas (BaseDbContext, Interceptors, BaseRepository, QueryableExtensions, Specifications, PersistenceResultExecutor, Configuracion).
Changelog
1.0.8
- 2026-09-10
- Referencia de proyecto y mejora de documentación (a1b16aa)
1.0.7
- 2026-09-05
- Añade Remove/RemoveRange al repositorio y mejora docs (185d61e)
1.0.6
- 2026-07-28
- chore: bump Akay.To.Core to 1.1.5 (1f3d65d)
1.0.5
- 2026-07-28
- feat: add outbox event writer (8aee3ea)
1.0.4
- 2026-07-21
- refactor: reorganize packages by capability (2d71c5a)
1.0.3
- 2026-07-16
- Change tracking audit (54372fa)
- feature/domainevents-outbox-trackchanges (7baacf8)
1.0.2
- 2026-07-14
- Domain events and Outbox (34b4d41)
1.0.1
- 2026-07-10
- chore: actualizado 1.0.1 (5c9fbf3)
0.0.4
- 2026-07-06
- chore: update nuget akay.to.core reference (87dbc84)
- feat: Add Specification Pattern (9c40708)
0.0.3
- 2026-07-02
- Merge branch 'main' of https://github.com/alvarocaballero/akay-to-ef (77e5b95)
- cambios en ci.yml para publicación de nuget (0be6f47)
0.0.2
- 2026-07-02
- Fix README.md (689ef04)
| 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
- Akay.To.Core (>= 1.1.11)
- Microsoft.EntityFrameworkCore (>= 10.0.9)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.9)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Akay.To.EF:
| Package | Downloads |
|---|---|
|
Akay.To.EF.SqlServer
SQL Server provider helpers for Akay.To.EF |
|
|
Akay.To.EF.Npgsql
PostgreSQL provider helpers for Akay.To.EF |
GitHub repositories
This package is not used by any popular GitHub repositories.