Seeds initial/default data into ABP apps using IDataSeedContributor and IDataSeeder. Supports per-tenant seeding and works with EF Core and MongoDB.
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 has its own data seed system (not EF Core's). It is modular, database-provider independent (works with EF Core and MongoDB), production-ready, and DI-enabled. Prefer it over EF Core's HasData seeding.
DataSeedContext.TenantId.HasData seeding — use ef-core-integration.SeedInSeparateUowAsync — use manage-units-of-work.Implement IDataSeedContributor (from Volo.Abp.Data). Register it for DI (e.g. ITransientDependency) and ABP discovers and runs it automatically as part of the seed process. The interface has a single method:
public interface IDataSeedContributor
{
Task SeedAsync(DataSeedContext context);
}
Example — seed one book only if the table is empty:
using System;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy;
public class BookStoreDataSeedContributor
: IDataSeedContributor, ITransientDependency
{
private readonly IRepository<Book, Guid> _bookRepository;
private readonly IGuidGenerator _guidGenerator;
private readonly ICurrentTenant _currentTenant;
public BookStoreDataSeedContributor(
IRepository<Book, Guid> bookRepository,
IGuidGenerator guidGenerator,
ICurrentTenant currentTenant)
{
_bookRepository = bookRepository;
_guidGenerator = guidGenerator;
_currentTenant = currentTenant;
}
public async Task SeedAsync(DataSeedContext context)
{
using (_currentTenant.Change(context?.TenantId))
{
if (await _bookRepository.GetCountAsync() > 0)
{
return;
}
var book = new Book(
id: _guidGenerator.Create(),
name: "The Hitchhiker's Guide to the Galaxy",
price: 42);
await _bookRepository.InsertAsync(book);
}
}
}
Guidelines:
GetCountAsync()) and return early if data already exists, so re-running the seeder is safe.DataSeedContext (from Volo.Abp.Data) carries the target tenant and free-form properties:
public class DataSeedContext
{
public Guid? TenantId { get; set; }
public Dictionary<string, object?> Properties { get; }
public object? this[string name] { get; set; } // shortcut for Properties[name]
public DataSeedContext(Guid? tenantId = null) { ... }
public virtual DataSeedContext WithProperty(string key, object? value); // fluent
}
To seed per tenant, honor context.TenantId. Wrap your logic in ICurrentTenant.Change(context?.TenantId) (as above) so entities are written in the correct tenant scope. TenantId == null means the host.
IDataSeeder is the entry point that runs all contributors:
public interface IDataSeeder
{
Task SeedAsync(DataSeedContext context);
}
You rarely call it directly in app code — the layered startup template's .DbMigrator console project already invokes it. When you do call it, pass configuration via properties, which contributors read from context:
// Read the admin credentials from configuration / a secret store — don't hardcode or commit them
await _dataSeeder.SeedAsync(
new DataSeedContext()
.WithProperty("AdminEmail", configuration["App:AdminEmail"])
.WithProperty("AdminPassword", configuration["App:AdminPassword"]));
Convenience overloads live in DataSeederExtensions:
// Seed for a specific tenant (wraps a new DataSeedContext(tenantId)):
await _dataSeeder.SeedAsync(tenantId);
// One separate unit of work per contributor — avoids DB timeouts when there
// are many contributors or a lot of data written in a single transaction.
// options must not be null (Begin runs Check.NotNull on it); pass
// requiresNew: true so each contributor gets its own independent UOW instead
// of a child of the seeder's ambient [UnitOfWork]:
await _dataSeeder.SeedInSeparateUowAsync(
tenantId: null,
options: new AbpUnitOfWorkOptions(),
requiresNew: true);
*.DbMigrator console app (in the layered startup template) migrates the schema and seeds data. Run it on each deploy. It also handles multi-tenant setups where each tenant has its own database, migrating and seeding every database. Running seeding in a dedicated app (rather than at web-app startup) makes app start faster and works safely in clustered/multi-instance deployments.IDataSeeder.SeedAsync() from the test base module's OnApplicationInitialization. To add data unique to tests, drop an extra IDataSeedContributor into the test project — it is discovered and run alongside the production contributors.*.DbMigrator console app (or IDataSeeder.SeedAsync()) and confirm the expected rows/documents appear in the database.GetCountAsync() early return) works.TenantId scope (and under the host when TenantId == null).SeedInSeparateUowAsync options must not be null — Begin runs Check.NotNull on it; pass new AbpUnitOfWorkOptions() and requiresNew: true so each contributor gets its own independent UOW instead of a child of the seeder's ambient [UnitOfWork].SeedInSeparateUowAsync to avoid DB timeouts.AdminEmail / AdminPassword from the context; don't re-implement what a module already seeds.context.TenantId writes data into the wrong tenant scope; always wrap logic in ICurrentTenant.Change(context?.TenantId).What SKILL.md sets; muted values are Claude Code's defaults
/abp-data-access:seed-application-datafrom abp-data-access
npx claudepluginhub abpframework/abp-skills --plugin abp-data-access9 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).
/manage-units-of-workControl ABP's Unit of Work — transaction and connection scope, explicit UOW scopes, the [UnitOfWork] attribute, and mid-scope SaveChangesAsync. USE FOR: starting explicit scopes with IUnitOfWorkManager.Begin, applying [UnitOfWork], choosing transactional vs non-transactional boundaries, calling SaveChangesAsync mid-scope, working with nested/RequiresNew/reserved scopes, reading IUnitOfWorkManager.Current, using OnCompleted/CompleteAsync/RollbackAsync. DO NOT USE FOR: defining a DbContext or repositories, or EF Core migrations (use ef-core-integration); MongoDB DbContext/repositories (use mongodb-integration); soft-delete/multi-tenant/custom query filters (use apply-data-filters); optimistic concurrency stamps (use handle-optimistic-concurrency); connection-string resolution (use configure-connection-strings).
/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).
Other plugins' skills for the same job