Enables ABP optimistic concurrency control via IHasConcurrencyStamp/ConcurrencyStamp, aggregate root base classes, and AbpDbConcurrencyException handling.
Ships in abp-data-access. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
ABP's concurrency check uses optimistic concurrency control: users can attempt to update the same record without being blocked up front. When one update wins, the others are rejected because the record has changed underneath them and must be re-read before retrying.
IHasConcurrencyStamp / ConcurrencyStamp.AbpDbConcurrencyException.IHasConcurrencyStampImplement this interface (directly or indirectly) to enable concurrency control on an entity:
public interface IHasConcurrencyStamp
{
string ConcurrencyStamp { get; set; }
}
How ABP uses the stamp:
AbpDbContext runs SetConcurrencyStampIfNull on added entities, so a null ConcurrencyStamp is filled in automatically. With MongoDB, insert does not set the stamp — the aggregate root base classes work only because their constructor generates one. A plain Entity<TKey>, IHasConcurrencyStamp on MongoDB must initialize ConcurrencyStamp itself.ConcurrencyStamp against the value stored in the database. If they match, it saves and ABP itself generates a new stamp (Guid.NewGuid().ToString("N") in framework code — not by the database). If they mismatch, it throws AbpDbConcurrencyException.The aggregate root base classes already implement IHasConcurrencyStamp, so deriving from any of these gives you concurrency control without implementing it yourself:
AggregateRoot, AggregateRoot<TKey>CreationAuditedAggregateRoot, CreationAuditedAggregateRoot<TKey>AuditedAggregateRoot, AuditedAggregateRoot<TKey>FullAuditedAggregateRoot, FullAuditedAggregateRoot<TKey>public class Book : FullAuditedAggregateRoot<Guid>
{
public string Name { get; set; }
//...
}
If your entity derives from a plain Entity<TKey>, implement the interface explicitly. On MongoDB, initialize the stamp yourself (EF Core fills a null stamp on insert, but MongoDB does not):
public class Book : Entity<Guid>, IHasConcurrencyStamp
{
public string ConcurrencyStamp { get; set; } = Guid.NewGuid().ToString("N");
//...
}
The stamp only protects an update if the client sends back the stamp it last read. So expose it on the output DTO and require it on the update DTO:
public class BookDto : EntityDto<Guid>, IHasConcurrencyStamp
{
public string ConcurrencyStamp { get; set; }
//...
}
public class UpdateBookDto : IHasConcurrencyStamp
{
public string ConcurrencyStamp { get; set; }
//...
}
In the application service's update method, copy the incoming stamp onto the entity before saving:
public class BookAppService : ApplicationService, IBookAppService
{
//...
public virtual async Task<BookDto> UpdateAsync(Guid id, UpdateBookDto input)
{
var book = await BookRepository.GetAsync(id);
book.ConcurrencyStamp = input.ConcurrencyStamp;
// ...set the other input values...
// autoSave: true flushes now, so the entity carries the new stamp
await BookRepository.UpdateAsync(book, autoSave: true);
return ObjectMapper.Map<Book, BookDto>(book);
}
}
Because the client received ConcurrencyStamp in BookDto and sent the same value in UpdateBookDto, a second user editing a stale copy will send an old stamp, the comparison mismatches, and AbpDbConcurrencyException is thrown.
The stamp is validated and the next one is generated by ABP framework code (Guid.NewGuid().ToString("N")), not by the database engine. When exactly the entity picks up the regenerated stamp is provider-specific. With EF Core, UpdateConcurrencyStamp runs at SaveChanges time, so inside a unit of work you must trigger a flush to read the new value — pass autoSave: true to UpdateAsync/InsertAsync (as above) or call CurrentUnitOfWork.SaveChangesAsync(); otherwise the entity holds the old stamp until the UOW completes. With MongoDB, UpdateAsync regenerates the stamp on the entity right before ReplaceOneAsync, independent of autoSave.
AbpDbConcurrencyExceptionAbpDbConcurrencyException lives in Volo.Abp.Data and derives from AbpException. You have two options:
try
{
await _bookAppService.UpdateAsync(id, input);
}
catch (AbpDbConcurrencyException)
{
// The record changed since it was loaded.
// Re-read the latest entity/DTO and let the user redo their edit.
}
Since resolving a conflict requires the caller to fetch the latest data and re-apply changes, the typical UX is: catch (or surface ABP's default message), reload the current record with its fresh ConcurrencyStamp, and let the user retry.
IHasConcurrencyStamp (directly or via an aggregate root base class) and that both the output and update DTOs carry ConcurrencyStamp.AbpDbConcurrencyException.UpdateAsync(book, autoSave: true) verify the returned DTO's ConcurrencyStamp differs from the one sent in — proving the stamp regenerated.Entity<TKey>, IHasConcurrencyStamp on MongoDB must initialize ConcurrencyStamp itself; EF Core fills it via SetConcurrencyStampIfNull, MongoDB does not.UpdateConcurrencyStamp runs at SaveChanges time, so inside a UOW the entity keeps the old stamp until you pass autoSave: true or call CurrentUnitOfWork.SaveChangesAsync().input.ConcurrencyStamp onto the entity before saving defeats the check — a stale client would silently overwrite the winner.Guid.NewGuid().ToString("N")) — don't expect a DB-generated rowversion.What SKILL.md sets; muted values are Claude Code's defaults
9 skills in this plugin
/apply-data-filtersWork with ABP data filters — the built-in ISoftDelete and IMultiTenant filters, toggling them via IDataFilter scopes, changing default states, and defining custom global query filters for EF Core or MongoDB. USE FOR: reading/writing soft-deleted or cross-tenant data with IDataFilter.Disable/Enable, checking IsEnabled, HardDeleteAsync, changing AbpDataFilterOptions defaults, defining a custom marker-interface filter, wiring it in EF Core (ShouldFilterEntity/CreateFilterExpression/HasAbpQueryFilter) or MongoDB (MongoDbRepositoryFilterer/FilterQueryable). DO NOT USE FOR: switching the active tenant context via ICurrentTenant.Change (that is the multi-tenancy concern); defining a DbContext/repositories or EF Core migrations (use ef-core-integration); MongoDB DbContext/repository setup (use mongodb-integration); transaction/UOW boundaries (use manage-units-of-work); optimistic concurrency (use handle-optimistic-concurrency).
/configure-connection-stringsConfigure ABP connection strings for modular and multi-tenant apps — the Default connection, per-module databases, grouping modules into one database, and per-tenant database routing. USE FOR: setting the Default connection, giving a module its own database with a named entry, binding a DbContext via [ConnectionStringName], mapping several modules to one DB with AbpDbConnectionOptions.Databases, routing a tenant to its own database, customizing IConnectionStringResolver. DO NOT USE FOR: EF Core DbContext registration/model config (use ef-core-integration), MongoDB client/database setup (use mongodb-integration), creating tenants or the tenant store (use configure-multi-tenancy), unit-of-work/transaction handling (use manage-units-of-work).
/abp-data-access:handle-optimistic-concurrencyfrom abp-data-access
npx claudepluginhub abpframework/abp-skills --plugin abp-data-accessOther plugins' skills for the same job