Albatross.EFCore
10.0.0-rc.127
Prefix Reserved
dotnet add package Albatross.EFCore --version 10.0.0-rc.127
NuGet\Install-Package Albatross.EFCore -Version 10.0.0-rc.127
<PackageReference Include="Albatross.EFCore" Version="10.0.0-rc.127" />
<PackageVersion Include="Albatross.EFCore" Version="10.0.0-rc.127" />
<PackageReference Include="Albatross.EFCore" />
paket add Albatross.EFCore --version 10.0.0-rc.127
#r "nuget: Albatross.EFCore, 10.0.0-rc.127"
#:package Albatross.EFCore@10.0.0-rc.127
#addin nuget:?package=Albatross.EFCore&version=10.0.0-rc.127&prerelease
#tool nuget:?package=Albatross.EFCore&version=10.0.0-rc.127&prerelease
Albatross.EFCore
A .NET library that wraps EF Core's DbContext in a clean session abstraction and provides opinionated patterns for entity mapping, repositories, change auditing, and cache eviction. Designed for layered enterprise applications where data access is strictly separated from business logic.
Key Features
- Session Abstraction -
IDbSession/DbSessionwrapsDbContextas a disposable unit-of-work; repositories depend on it, services never do - Entity Mapping Convention - Co-locate entities with their
EntityMap<T>class; theAlbatross.EFCore.CodeGensource generator auto-registers all maps viamodelBuilder.BuildEntityModels() - Semantic Exception Conversion -
Repository<T>.SaveChangesAsyncconverts database constraint violations into semantic exceptions (ConflictException,NotFoundException,PreconditionFailedException) viaISemanticExceptionConverter - Change Report Interceptor -
ChangeReportInterceptor<TEntity>captures per-property before/after snapshots and invokes a callback after each successful save - Audit Trail Interceptor -
ChangeAuditInterceptor<TChangeEntity, TEntityId, TActorId>writes typed audit records for everyIAuditable<T>entity that is modified or deleted - Cache Eviction Interceptor -
CacheEvictionInterceptortriggers cache invalidation for modified or deleted entities post-save - JSON Column Helpers -
HasImmutableJsonProperty<T>andHasJsonCollectionProperty<T>map complex types tovarchar(max)JSON columns with correct change-tracking semantics - UTC DateTime Fix -
UtcDateTimeProperty()ensuresDateTimecolumns round-trip withDateTimeKind.Utc
Quick Start
Define a session, an entity with its map, and a repository:
// 1. Session — one per bounded context
using Crm.AutoGenerated; // where the source generator puts BuildEntityModels()
public interface ICrmDbSession : IDbSession { }
public class CrmDbSession : DbSession, ICrmDbSession {
public CrmDbSession(DbContextOptions options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.HasDefaultSchema("crm");
modelBuilder.BuildEntityModels(); // auto-registers all EntityMap<T> in this assembly
}
}
// 2. Entity + map in the same file
public class Company {
public required Guid Id { get; init; }
[MaxLength(256)] public required string Name { get; set; }
}
public class CompanyEntityMap : EntityMap<Company> {
public override void Map(EntityTypeBuilder<Company> builder) {
builder.HasKey(x => x.Id);
builder.Property(x => x.Id).ValueGeneratedNever();
builder.HasIndex(x => x.Name).IsUnique();
}
}
// 3. Repository — one per aggregate root
public class CompanyRepository : Repository<ICrmDbSession> {
public CompanyRepository(ICrmDbSession session, ISemanticExceptionConverter converter) : base(session, converter) { }
public async Task<Company> GetById(Guid id, CancellationToken ct) {
var entity = await session.DbContext.Set<Company>()
.FirstOrDefaultAsync(x => x.Id == id, ct);
if (entity == null) throw new NotFoundException<Company>(id);
return entity;
}
}
// 4. Save at the application boundary (controller / command handler)
await repository.SaveChangesAsync(cancellationToken);
// Constraint violations throw semantic exceptions (ConflictException, NotFoundException, PreconditionFailedException)
Dependencies
- Microsoft.EntityFrameworkCore 10.0.5+
- Microsoft.EntityFrameworkCore.Relational 10.0.5+
- Microsoft.Extensions.DependencyInjection.Abstractions 10.0.5+
Prerequisites
- .NET 10.0+
- C# Compiler 4.12.0+ — required by the
Albatross.EFCore.CodeGensource generator. Satisfied by .NET 9 SDK or Visual Studio 2022 with .NET 8. When using .NET 8 SDK with VS Code, Rider, or a terminal, addMicrosoft.Net.Compilers.Toolset 4.12.0+to your project.
Documentation
| 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
- Albatross.Exceptions (>= 1.0.0)
- Microsoft.EntityFrameworkCore (>= 10.0.9)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Albatross.EFCore:
| Package | Downloads |
|---|---|
|
Albatross.EFCore.SqlServer
SqlServer Setup for Albatross.EFCore |
|
|
Albatross.EFCore.PostgreSQL
PostgresSQL Setup for Albatross.EFCore |
|
|
Albatross.EFCore.ChangeReporting
Package Description |
|
|
Albatross.EFCore.AutoCacheEviction
Package Description |
|
|
Albatross.EFCore.Admin
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0-rc.127 | 75 | 7/28/2026 |
| 10.0.0-rc.124 | 70 | 7/24/2026 |
| 10.0.0-rc.121 | 69 | 7/17/2026 |
| 10.0.0-rc.117 | 82 | 7/11/2026 |
| 10.0.0-rc.113 | 86 | 7/8/2026 |
| 10.0.0-rc.112 | 90 | 7/8/2026 |