Controls ABP's Unit of Work system: transaction/connection scopes, explicit UOW scopes, the [UnitOfWork] attribute, and mid-scope SaveChangesAsync. Useful for background jobs, console apps, or custom transaction boundaries.
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 Unit of Work (UOW) controls the database connection and transaction scope. Once a UOW starts it creates an ambient scope: every database operation done inside it participates in one boundary and is committed on success or rolled back on exception, all together.
IUnitOfWorkManager.Begin.[UnitOfWork].SaveChangesAsync (e.g. to read an auto-increment id).RequiresNew/reserved scopes, or hooking OnCompleted.These method types are conventionally wrapped in a UOW and completed automatically when they return without throwing:
A UOW auto-begins for these unless there is already a surrounding (ambient) UOW — in that case the inner call silently participates in the outer one. So a repository called from an app service does not open its own UOW; it joins the app service's UOW. This is why you rarely start a UOW yourself.
A UOW does not have to be transactional. By default:
AspNetCoreUnitOfWorkTransactionBehaviourProviderOptions.NonTransactionalUrls.Change the global default via AbpUnitOfWorkDefaultOptions in your module's ConfigureServices:
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; // or Enabled / Auto
});
AbpUnitOfWorkDefaultOptions also exposes Timeout (int?) and IsolationLevel (IsolationLevel?).
[UnitOfWork] attributePut [UnitOfWork] on a method or a class to enable/disable a UOW and control its transaction behavior. Interception rules: if you don't inject the service over an interface, the method must be virtual; only async methods (returning Task/Task<T>) are intercepted.
public class MyService : ITransientDependency
{
[UnitOfWork(IsTransactional = true)]
public virtual async Task FooAsync() { /* transactional UOW scope */ }
}
Attribute properties (from UnitOfWorkAttribute):
IsTransactional (bool?) — null means "decide by convention/config".Timeout (int?) — milliseconds.IsolationLevel (IsolationLevel?) — only meaningful when transactional.IsDisabled (bool) — prevent starting a UOW for this method/class.[UnitOfWork(IsDisabled = true)]
public virtual async Task NoUowAsync() { /* ... */ }
Important: if the method is called inside an ambient UOW, the attribute is ignored — the method just participates in the surrounding UOW. [UnitOfWork] only takes effect when it is the outermost scope.
IUnitOfWorkManager.BeginInject IUnitOfWorkManager when you need a UOW outside the conventions (background jobs, console apps, or an inner scope). The convenient extension overload:
public class MyService : ITransientDependency
{
private readonly IUnitOfWorkManager _unitOfWorkManager;
public MyService(IUnitOfWorkManager unitOfWorkManager)
{
_unitOfWorkManager = unitOfWorkManager;
}
public virtual async Task FooAsync()
{
using (var uow = _unitOfWorkManager.Begin(
requiresNew: true, isTransactional: true))
{
// ... database operations ...
await uow.CompleteAsync(); // must call, or it rolls back on dispose
}
}
}
Begin(requiresNew = false, isTransactional = false, isolationLevel = null, timeout = null):
requiresNew — false (default): if a surrounding UOW exists, Begin does not open a new one, it silently joins the existing UOW. true: ignore the ambient UOW and start a fresh, independent one (its own transaction).Begin, you own its completion: call await uow.CompleteAsync() before leaving the using. If you don't complete it, disposing rolls it back.There is also the lower-level Begin(AbpUnitOfWorkOptions options, bool requiresNew = false) on the interface itself.
SaveChangesAsyncUOW is ambient — reach it via IUnitOfWorkManager.Current (an IUnitOfWork), which is null when there is no surrounding UOW.
IUnitOfWork.SaveChangesAsync() flushes pending changes to the database mid-scope without ending the UOW. If the UOW is transactional, even those saved changes can still be rolled back on a later error. Typical use — get an auto-increment id right after insert:
public class CategoryAppService : ApplicationService, ICategoryAppService
{
private readonly IRepository<Category, int> _categoryRepository;
public CategoryAppService(IRepository<Category, int> categoryRepository)
=> _categoryRepository = categoryRepository;
public async Task<int> CreateAsync(string name)
{
var category = new Category { Name = name };
await _categoryRepository.InsertAsync(category);
await CurrentUnitOfWork.SaveChangesAsync(); // or UnitOfWorkManager.Current.SaveChangesAsync()
return category.Id;
}
}
ApplicationService already exposes UnitOfWorkManager and the CurrentUnitOfWork shortcut, so you don't inject them there.
SaveChangesAsync() (or InsertAsync(..., autoSave: true)) when you truly need the flush now.Guid primary key you never need to save just to get the id — it's set in-app immediately.Begin(requiresNew: true, ...) inside an existing scope to run an independent inner transaction that commits or rolls back separately from the outer one. Without requiresNew, the inner Begin just joins the outer UOW.IUnitOfWorkManager.Reserve(reservationName, requiresNew) reserves a UOW slot up the stack; later BeginReserved(reservationName, options) / TryBeginReserved(...) starts the actual UOW under that reservation. IUnitOfWork.IsReserved and ReservationName reflect this. This is an advanced mechanism used internally (e.g. to make the outermost UOW transactional after inner code has already begun).IUnitOfWork membersCompleteAsync() / RollbackAsync() — commit or roll back a manually-started UOW.OnCompleted(Func<Task>) — run a callback after the UOW successfully completes (changes are guaranteed saved). See the callback pattern below.Failed / Disposed events — react to failure or disposal.Items — a Dictionary<string, object> to stash arbitrary state scoped to this UOW.Options, Outer — the options it was started with and the enclosing UOW (if nested).OnCompleted callbackThe callback runs right after the commit, inside whatever DI scope and CurrentTenant are active when CompleteAsync runs; it keeps nothing from the moment it was registered. That matters when the code that registered it has already finished. A DI-registered local event handler is the common case: an event published inside a unit of work is handled during CompleteAsync, and the handler's scope is disposed and its event tenant restored before the commit. A disposed scope has disposed the disposable transient and scoped services it created (singletons are not), and a Lazy<T> built in it throws ObjectDisposedException on its first read. In such a callback, pass plain values, including the tenant id, and resolve services in a new scope:
public class OrderShippedHandler : ILocalEventHandler<OrderShippedEto>, ITransientDependency
{
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly ICurrentTenant _currentTenant;
private readonly IServiceScopeFactory _scopeFactory;
public OrderShippedHandler(
IUnitOfWorkManager unitOfWorkManager,
ICurrentTenant currentTenant,
IServiceScopeFactory scopeFactory)
{
_unitOfWorkManager = unitOfWorkManager;
_currentTenant = currentTenant;
_scopeFactory = scopeFactory;
}
public Task HandleEventAsync(OrderShippedEto eventData)
{
var orderId = eventData.OrderId;
var tenantId = _currentTenant.Id; // the event's tenant while the handler runs
_unitOfWorkManager.Current!.OnCompleted(async () =>
{
using var scope = _scopeFactory.CreateScope();
var currentTenant = scope.ServiceProvider.GetRequiredService<ICurrentTenant>();
using (currentTenant.Change(tenantId))
{
var notifier = scope.ServiceProvider.GetRequiredService<IOrderNotifier>();
await notifier.NotifyShippedAsync(orderId);
}
});
return Task.CompletedTask;
}
}
The handler relies on the event being published inside a unit of work (the default PublishAsync queues it there); Current is null when there is none. IServiceScopeFactory is a singleton with the Autofac integration, so a factory injected into a short-lived service still works inside the callback.
The UOW system is fully integrated via action/page filters — normally zero config. If you need to widen the scope across other middleware, add app.UseUnitOfWork(); before app.UseConfiguredEndpoints();. UseUnitOfWork() is an IApplicationBuilder extension in the Microsoft.AspNetCore.Builder namespace, shipped by the Volo.Abp.AspNetCore package — a plain console/background-worker host that only references Volo.Abp.Uow won't have it.
IUnitOfWorkManager.Current is non-null; outside any scope it is null.Begin scope must call await uow.CompleteAsync() to commit. Skipping it means an open transaction is never committed (and is disposed on Dispose()), so those changes are not persisted — but note this only covers work still buffered in an uncommitted transaction; non-transactional writes that already reached the database are not undone.AbpUnitOfWorkDefaultOptions and any NonTransactionalUrls).[UnitOfWork] takes effect only as the outermost scope — verify it is not being called inside an existing ambient UOW where it is ignored.[UnitOfWork] ignored inside an ambient UOW — the attribute only takes effect when it is the outermost scope; an inner call just joins the surrounding UOW.CompleteAsync() on a manual Begin — Dispose() disposes the transaction without committing it (it does not call RollbackAllAsync), so an uncommitted transactional UOW discards its changes — even writes already flushed with SaveChangesAsync are rolled back when the transaction is disposed (the real commit happens in CompleteAsync). What cannot be undone this way is writes made without a transaction, which hit the database as they happen.Begin without requiresNew: true inside an existing scope silently joins the outer UOW instead of starting an independent transaction.[UnitOfWork] not intercepted — the method must be async (Task/Task<T>), and virtual when the service is not injected over an interface.SaveChangesAsync() — changes flush automatically when the UOW ends; with a Guid PK you never need it just to read the id.IUnitOfWorkManager.Current is null when no UOW surrounds the call — guard for it outside conventional scopes.OnCompleted callback — a local event handler's scope and event tenant end before the commit, so its callback fails or runs as the tenant active at completion after the data is committed. Pass plain values and use a new scope with the tenant restored.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).
/ef-core-integrationIntegrate Entity Framework Core into an ABP application: AbpDbContext, AddAbpDbContext registration, default/custom repositories, and code-first migrations with DbMigrator. USE FOR: defining an AbpDbContext with ConfigureByConvention, registering it via AddAbpDbContext, wiring AddDefaultRepositories/AddRepository, writing custom EfCoreRepository classes, resolving the active DbContext via IDbContextProvider, adding dotnet ef migrations, running the DbMigrator. DO NOT USE FOR: consuming the standard IRepository method surface — Get/Find/WithDetails/queryable/bulk (use-abp-repositories); MongoDB integration (use mongodb-integration); controlling transaction/UOW boundaries (use manage-units-of-work); soft-delete/multi-tenant/custom query filters (use apply-data-filters); optimistic concurrency stamps (use handle-optimistic-concurrency); Dapper queries (use query-with-dapper); connection-string resolution/config (use configure-connection-strings); seeding data via IDataSeeder (use seed-application-data).
/handle-optimistic-concurrencyEnable and handle ABP optimistic concurrency control so concurrent updates to the same record are detected and rejected. USE FOR: enabling concurrency with IHasConcurrencyStamp/ConcurrencyStamp, deriving from aggregate root base classes to get it for free, flowing the stamp through output and update DTOs, handling AbpDbConcurrencyException when two users update the same record. DO NOT USE FOR: EF-Core-specific mapping/change tracking (use ef-core-integration), MongoDB provider setup (use mongodb-integration), unit-of-work flush/transaction control (use manage-units-of-work), general validation/error surfacing (use handle-validation-and-errors).
/mongodb-integrationIntegrate MongoDB into an ABP application: AbpMongoDbContext, collection mapping, AddMongoDbContext registration, and custom Mongo repositories. USE FOR: defining an AbpMongoDbContext, mapping collections with [MongoCollection]/CreateModel, registering via AddMongoDbContext, wiring AddDefaultRepositories/AddRepository, writing custom MongoDbRepository classes, reaching the DbContext via IMongoDbContextProvider, using GetCollectionAsync/GetAggregateAsync. DO NOT USE FOR: consuming standard IRepository methods (use-abp-repositories); Entity Framework Core integration, DbContext model builder, or code-first migrations (use ef-core-integration); controlling transaction/UOW boundaries (use manage-units-of-work); soft-delete/multi-tenant/custom query filters or MongoDbRepositoryFilterer (use apply-data-filters); optimistic concurrency (use handle-optimistic-concurrency); connection-string configuration (use configure-connection-strings); seeding data via IDataSeeder (use seed-application-data).
/query-with-dapperRun raw SQL via Dapper inside an ABP repository for hot-path read/aggregate queries while sharing ABP's unit of work, connection, and transaction. USE FOR: complex or slow queries where EF Core's generated SQL is too slow, hand-written SQL you want full control over, deriving from a DbContext-based DapperRepository and using GetDbConnectionAsync/GetDbTransactionAsync to stay in the current unit of work. DO NOT USE FOR: standard CRUD/LINQ/change tracking/migrations (use ef-core-integration), MongoDB queries (use mongodb-integration), unit-of-work configuration itself (use manage-units-of-work), connection string routing (use configure-connection-strings).
/abp-data-access:manage-units-of-workfrom abp-data-access
npx claudepluginhub abpframework/abp-skills --plugin abp-data-accessOther plugins' skills for the same job