BB84.EntityFrameworkCore.Entities.Abstractions
5.0.1125
dotnet add package BB84.EntityFrameworkCore.Entities.Abstractions --version 5.0.1125
NuGet\Install-Package BB84.EntityFrameworkCore.Entities.Abstractions -Version 5.0.1125
<PackageReference Include="BB84.EntityFrameworkCore.Entities.Abstractions" Version="5.0.1125" />
<PackageVersion Include="BB84.EntityFrameworkCore.Entities.Abstractions" Version="5.0.1125" />
<PackageReference Include="BB84.EntityFrameworkCore.Entities.Abstractions" />
paket add BB84.EntityFrameworkCore.Entities.Abstractions --version 5.0.1125
#r "nuget: BB84.EntityFrameworkCore.Entities.Abstractions, 5.0.1125"
#:package BB84.EntityFrameworkCore.Entities.Abstractions@5.0.1125
#addin nuget:?package=BB84.EntityFrameworkCore.Entities.Abstractions&version=5.0.1125
#tool nuget:?package=BB84.EntityFrameworkCore.Entities.Abstractions&version=5.0.1125
BB84.EntityFrameworkCore.Entities.Abstractions
This package provides the core entity interface definitions. It has no external dependencies.
Installation
dotnet add package BB84.EntityFrameworkCore.Entities.Abstractions
Component interfaces
These fine-grained interfaces are the building blocks composed by the entity-level interfaces below.
| Interface | Members |
|---|---|
IIdentity<TKey> |
TKey Id |
IConcurrency<TToken> |
TToken Timestamp |
IConcurrency |
Shorthand: IConcurrency<byte[]> (rowversion) |
ITimeAudited |
DateTimeOffset CreatedAt, DateTimeOffset? EditedAt |
IUserAudited<TCreator, TEditor> |
TCreator CreatedBy, TEditor EditedBy |
IUserAudited |
Shorthand: IUserAudited<string, string?> |
ISoftDeletable |
bool IsDeleted |
IEnumeration |
string Name, string? Description |
Entity interfaces
Each entity interface composes the component interfaces above. Convenience overloads default TKey to Guid and TCreator/TEditor to string/string?.
IIdentityEntity<TKey, TToken> and overloads
Inherits IIdentity<TKey> and IConcurrency<TToken>. The base for all identity-keyed entities. The overloads default TToken to byte[] and TKey to Guid.
public interface IIdentityEntity<TKey, TToken> : IIdentity<TKey>, IConcurrency<TToken>
where TKey : IEquatable<TKey>
public interface IIdentityEntity<TKey> : IIdentityEntity<TKey, byte[]>
where TKey : IEquatable<TKey>
public interface IIdentityEntity : IIdentityEntity<Guid>
IAuditedEntity<TKey, TCreator, TEditor> and overloads
Extends IIdentityEntity<TKey> with IUserAudited<TCreator, TEditor>.
// Full generic form
public interface IAuditedEntity<TKey, TCreator, TEditor> : IIdentityEntity<TKey>, IUserAudited<TCreator, TEditor>
// Defaults TCreator/TEditor to string/string?
public interface IAuditedEntity<TKey> : IAuditedEntity<TKey, string, string?>
// Defaults TKey to Guid, TCreator/TEditor to string/string?
public interface IAuditedEntity : IAuditedEntity<Guid, string, string?>
IFullAuditedEntity<TKey, TCreator, TEditor> and overloads
Extends IIdentityEntity<TKey> with both IUserAudited and ITimeAudited.
// Full generic form
public interface IFullAuditedEntity<TKey, TCreator, TEditor> : IIdentityEntity<TKey>, IUserAudited<TCreator, TEditor>, ITimeAudited
// Convenience overloads mirror the same pattern as IAuditedEntity
public interface IFullAuditedEntity<TKey> : IFullAuditedEntity<TKey, string, string?>
public interface IFullAuditedEntity : IFullAuditedEntity<Guid, string, string?>
ICompositeEntity<TToken> / ICompositeEntity
For entities with composite primary keys — inherits only IConcurrency<TToken>.
public interface ICompositeEntity<TToken> : IConcurrency<TToken>
public interface ICompositeEntity : ICompositeEntity<byte[]>
IAuditedCompositeEntity<TCreator, TEditor> / IAuditedCompositeEntity
Extends ICompositeEntity with IUserAudited. The non-generic overload defaults to string/string?.
IEnumeratorEntity<TKey> / IEnumeratorEntity
Lookup/reference data. Extends IIdentityEntity<TKey> with IEnumeration and ISoftDeletable. The non-generic overload defaults TKey to int.
public interface IEnumeratorEntity<TKey, TToken> : IIdentityEntity<TKey, TToken>, IEnumeration, ISoftDeletable
where TKey : IEquatable<TKey>
public interface IEnumeratorEntity<TKey> : IEnumeratorEntity<TKey, byte[]>
where TKey : IEquatable<TKey>
public interface IEnumeratorEntity : IEnumeratorEntity<int>
Concurrency tokens
IConcurrency<TToken>.Timestamp is settable, which is what makes the disconnected update work. An entity is read, mapped to a DTO, sent over the wire and posted back; assign the original token onto the reconstructed entity before updating it, so it reaches the WHERE predicate:
OrderEntity entity = new()
{
Id = dto.Id,
TotalAmount = dto.TotalAmount,
Timestamp = dto.Timestamp // the value read earlier
};
repository.Update(entity);
try
{
await context.SaveChangesAsync(cancellationToken);
}
catch (DbUpdateConcurrencyException)
{
// another transaction changed the row in the meantime
}
Leave Timestamp unset and the update is not guarded — it succeeds regardless of what happened to the row in between. The value is store generated, so never assign it on a newly created entity, and never assign anything other than a value read from the database.
Choosing the token type
TToken is the provider's business. byte[] is what the short rungs default to and what SQL Server rowversion needs; PostgreSQL xmin is a uint; a Guid or an incrementing int rotated by the application works too. Name the type on the widest rung of the ladder to pick something else:
// rowversion, the default
public sealed class OrderEntity : IdentityEntity { }
// a Guid token instead
public sealed class OrderEntity : IdentityEntity<Guid, Guid> { }
Whatever the type, the store has to be told to generate it. The configuration base classes in BB84.EntityFrameworkCore.Repositories take a matching TToken and mark the property as a concurrency token generated on add or update — which is right for rowversion and for xmin, but not for a token the application rotates itself. Override the generation strategy after calling base.Configure(builder) in that case.
Changed in 5.0:
Timestampwas get-only before, so the original value could not be restored on a detached entity and optimistic concurrency never fired for the case it exists for. Hand-written implementations ofIConcurrencyneed a setter added. The shipped entities also start out with an empty array rather thannull.
Changed in 5.0: the token type is a type parameter —
IConcurrency<TToken>, withIConcurrencykept as thebyte[]shorthand. Code namingIConcurrencyis unaffected; the entity and configuration ladders each gained a rung that names the token type.
Usage
Implement these interfaces directly on your domain entities, or use them as constraints in repository and service abstractions:
// Custom entity interface
public interface IOrderEntity : IAuditedEntity
{
decimal TotalAmount { get; set; }
}
// Custom repository interface constrained to the abstraction
public interface IOrderRepository : IIdentityRepository<IOrderEntity>
{
Task<IReadOnlyList<IOrderEntity>> GetByCustomerAsync(Guid customerId, CancellationToken token = default);
}
| 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
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on BB84.EntityFrameworkCore.Entities.Abstractions:
| Package | Downloads |
|---|---|
|
BB84.EntityFrameworkCore.Repositories.Abstractions
This package contains frequently used repository abstractions. |
|
|
BB84.EntityFrameworkCore.Entities
This package contains frequently used model implementations of their respective abstractions. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 5.0.1125 | 49 | 11/25/2026 | |
| 5.0.1123 | 93 | 11/23/2026 | |
| 5.0.1118 | 154 | 11/18/2026 | |
| 5.0.1027 | 342 | 10/27/2026 | |
| 5.0.1020 | 185 | 10/20/2026 | |
| 5.0.916 | 444 | 9/16/2026 | |
| 5.0.818 | 446 | 8/18/2026 | |
| 4.5.725 | 302 | 7/25/2026 | |
| 4.4.724 | 231 | 7/24/2026 | |
| 4.4.625 | 316 | 6/25/2026 | |
| 4.3.520 | 413 | 5/20/2026 | |
| 4.3.513 | 281 | 5/13/2026 | |
| 4.3.507 | 234 | 5/7/2026 | |
| 4.3.419 | 311 | 4/19/2026 | |
| 4.3.327 | 363 | 3/27/2026 | |
| 4.2.322 | 249 | 3/22/2026 | |
| 4.1.319 | 210 | 3/19/2026 | |
| 4.1.222 | 296 | 2/22/2026 | |
| 4.1.122 | 296 | 1/22/2026 | |
| 4.0.1026 | 477 | 10/26/2025 |