Defines AbpMongoDbContext, maps collections, registers via AddMongoDbContext, and creates custom MongoDbRepository classes for ABP applications.
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.
Guidance for the MongoDB data-access layer of an ABP solution. Types live in Volo.Abp.MongoDB. The integration lives in the *.MongoDB project; repository interfaces belong in the *.Domain project.
AbpMongoDbContext and exposing collections as IMongoCollection<T>.[MongoCollection] and mapping entities in CreateModel.AddMongoDbContext.MongoDbRepository<TMongoDbContext, TEntity, TKey>.IMongoDbContextProvider<TMongoDbContext>, or dropping to the native driver with GetCollectionAsync() / GetAggregateAsync().OnModelCreating, or dotnet ef migrations — use the ef-core-integration skill instead.MongoDbRepositoryFilterer) — use apply-data-filters.Derive from AbpMongoDbContext. Expose each collection as an IMongoCollection<T> property and mark it with [MongoCollection] (from Volo.Abp.MongoDB) to name the collection. Attach the module's model configuration by overriding CreateModel.
[ConnectionStringName("Default")]
public class MyProjectMongoDbContext : AbpMongoDbContext
{
[MongoCollection("AppBooks")]
public IMongoCollection<Book> Books => Collection<Book>();
protected override void CreateModel(IMongoModelBuilder modelBuilder)
{
base.CreateModel(modelBuilder);
modelBuilder.Entity<Book>(b =>
{
b.CollectionName = "AppBooks";
});
}
}
[MongoCollection] sets the collection name (CollectionName on the attribute); without it the DbContext collection property name is used (e.g. the Books property maps to a Books collection).Collection<T>() (defined on AbpMongoDbContext) returns the underlying IMongoCollection<T>.IMongoModelBuilder.Entity<TEntity>(...) maps an entity; set CollectionName, indexes, or a BSON class map there.AbpMongoDbContext.CreateModel is empty; calling base.CreateModel(modelBuilder) is a harmless convention, not a requirement that wires up ABP's entities.Reusable modules ship a builder.Configure<Module>() extension on IMongoModelBuilder. Call them inside CreateModel:
modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement();
Register in your *.MongoDB module's ConfigureServices via AddMongoDbContext<TMongoDbContext>:
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddMongoDbContext<MyProjectMongoDbContext>(options =>
{
options.AddDefaultRepositories(includeAllEntities: true);
// Custom repository override
options.AddRepository<Book, MongoDbBookRepository>();
});
}
The registration builder shares the same API as EF Core: AddDefaultRepositories, AddDefaultRepository<TEntity>(), AddRepository<TEntity, TRepository>().
Declare the interface in the Domain project (same as EF Core — IRepository<TEntity, TKey>):
public interface IBookRepository : IRepository<Book, Guid>
{
Task<List<Book>> GetListByAuthorAsync(Guid authorId);
}
IRepository is the right base inside a final application. For a reusable module published for other apps, extend IBasicRepository<Book, Guid> (or IReadOnlyBasicRepository) instead, so consumers aren't coupled to a provider's IQueryable (see use-abp-repositories).
Implement in the MongoDB project by deriving from MongoDbRepository<TMongoDbContext, TEntity, TKey>:
public class MongoDbBookRepository
: MongoDbRepository<MyProjectMongoDbContext, Book, Guid>, IBookRepository
{
public MongoDbBookRepository(IMongoDbContextProvider<MyProjectMongoDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
public async Task<List<Book>> GetListByAuthorAsync(Guid authorId)
{
var queryable = await GetQueryableAsync();
return await queryable.Where(b => b.AuthorId == authorId).ToListAsync();
}
}
GetQueryableAsync() → IQueryable<TEntity> (LINQ over the collection; the driver translates it).GetCollectionAsync() → the raw IMongoCollection<TEntity> for native driver operations (aggregation, bulk writes).GetAggregateAsync() → an IAggregateFluent<TEntity> for aggregation pipelines.The base repository already applies ABP's global filters (soft-delete, multi-tenancy) to GetQueryableAsync(); going through the raw collection bypasses them.
Inject IMongoDbContextProvider<TMongoDbContext> to reach the DbContext directly and get another collection:
var dbContext = await _dbContextProvider.GetDbContextAsync();
var authors = dbContext.Collection<Author>();
dotnet ef migrations step. The startup template's schema migrator (MongoDb...DbSchemaMigrator) instead calls InitializeCollections, which creates the collections and any configured indexes; the DbMigrator console app (if present) also runs IDataSeeder to seed data.GetAggregateAsync() / $lookup only when a real aggregation pipeline is needed.[MongoCollection], not table mapping.AddDefaultRepositories, custom repository pattern, [ConnectionStringName] — mirrors the EF Core integration, so application/domain code stays provider-agnostic.*.MongoDB project references Volo.Abp.MongoDB; the DbContext derives from AbpMongoDbContext and carries [ConnectionStringName].IRepository<Book, Guid> (or your IBookRepository) resolves after AddMongoDbContext registration — confirm the app boots and the repository is available.GetQueryableAsync(); a native GetCollectionAsync() query returns unfiltered rows.Volo.Abp.MongoDB — repository interfaces stay provider-agnostic.GetCollectionAsync()) unexpectedly bypasses ABP's global filters (soft-delete, multi-tenancy). Use GetQueryableAsync() unless you deliberately need native driver operations.$lookup/GetAggregateAsync() only for real aggregation pipelines.dotnet ef migrations — MongoDB has none. The template's schema migrator calls InitializeCollections to create collections and configured indexes, and the DbMigrator (if present) additionally seeds data.[MongoCollection] — the collection is then named after the property, which may not match your intended collection name.What SKILL.md sets; muted values are Claude Code's defaults
/abp-data-access:mongodb-integrationfrom 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).
Other plugins' skills for the same job