Franz.Common.MongoDB
3.0.0
dotnet add package Franz.Common.MongoDB --version 3.0.0
NuGet\Install-Package Franz.Common.MongoDB -Version 3.0.0
<PackageReference Include="Franz.Common.MongoDB" Version="3.0.0" />
<PackageVersion Include="Franz.Common.MongoDB" Version="3.0.0" />
<PackageReference Include="Franz.Common.MongoDB" />
paket add Franz.Common.MongoDB --version 3.0.0
#r "nuget: Franz.Common.MongoDB, 3.0.0"
#:package Franz.Common.MongoDB@3.0.0
#addin nuget:?package=Franz.Common.MongoDB&version=3.0.0
#tool nuget:?package=Franz.Common.MongoDB&version=3.0.0
Franz.Common.MongoDB
MongoDB context, tenant-aware repository, aggregate repository, and messaging-store integrations.
Overview
The package provides a MongoDB context registration helper, native tenant-scoped repositories, and Mongo-backed outbox/inbox storage. It does not provide an EF Core provider.
Installation
dotnet add package Franz.Common.MongoDB
Register a Mongo context
The registration helper reads MongoDb:ConnectionString and MongoDb:DatabaseName, registers IMongoClient as a singleton, registers IMongoDatabase and the concrete context as scoped services:
using Franz.Common.MongoDB.Extensions;
using Franz.Common.MongoDB.Configuration;
var mongoSection = builder.Configuration.GetSection("MongoDb");
builder.Services.Configure<MongoDBConfig>(options =>
{
options.ConnectionString = mongoSection["ConnectionString"];
options.Database = mongoSection["DatabaseName"];
options.Collection = mongoSection["Collection"];
});
builder.Services.AddMongoDbContext<ApplicationMongoContext>(builder.Configuration);
The explicit Configure<MongoDBConfig> mapping is required when the context derives from MongoDbContext, because that base context consumes IOptions<MongoDBConfig> and reads its Database property. AddMongoDbContext reads MongoDb:ConnectionString and MongoDb:DatabaseName for client/database registration but does not bind MongoDBConfig; the options mapping must translate DatabaseName to Database as shown.
{
"MongoDb": {
"ConnectionString": "<secret>",
"DatabaseName": "application",
"Collection": "customers"
}
}
Tenant-aware native repositories
For documents implementing IMongoTenantEntity:
builder.Services.AddMongoTenantRepository<CustomerDocument>("customers");
The registration adds the concrete MongoTenantRepository<CustomerDocument> to DI; it does not register a separate repository interface. The repository requires IMongoDatabase and a scoped ITenantExecutionContextAccessor, and every read/mutation includes the validated tenant ID in the MongoDB filter. Inserts stamp an empty TenantId from the current context and reject cross-tenant ownership.
For event-sourced aggregate repositories:
builder.Services.AddMongoTenantAggregateRepository<OrderAggregate, OrderEvent>();
This registration adds the concrete MongoAggregateRepository<TAggregate, TEvent> to DI and requires the scoped tenant execution context plus Mediator dispatcher. The class implements IAggregateRepository<TAggregate, TEvent>, but the helper registers only the concrete type; add an explicit IAggregateRepository<TAggregate, TEvent> mapping if the application resolves the repository through that abstraction. It is an event-store repository that persists and replays tenant-filtered domain events.
Messaging stores
builder.Services.AddMongoMessageStore(
connectionString: mongoConnectionString,
dbName: "messaging",
outboxCollectionName: "OutboxMessages",
deadLetterCollectionName: "DeadLetterMessages");
The helper registers Mongo client/database instances, IMessageStore, and IInboxStore as singletons. It takes the connection string and database name directly; configure those values explicitly at the registration call. This messaging-store registration is not tenant-scoped by the helper.
Use a secret manager for connection strings. Do not reuse tenant-scoped DbContexts or repository scopes across tenant execution boundaries.
License
MIT. See the repository LICENSE.
| 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
- Franz.Common.Business (>= 3.0.0)
- Franz.Common.DependencyInjection (>= 3.0.0)
- Franz.Common.EntityFramework (>= 3.0.0)
- Franz.Common.Errors (>= 3.0.0)
- Franz.Common.Http.MultiTenancy (>= 3.0.0)
- Franz.Common.Mediator (>= 3.0.0)
- Franz.Common.Messaging (>= 3.0.0)
- Franz.Common.MultiTenancy (>= 3.0.0)
- MongoDB.Driver (>= 3.12.0)
- SharpCompress (>= 0.50.7)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Franz.Common.MongoDB:
| Package | Downloads |
|---|---|
|
Franz.Common.Http.EntityFramework
Shared utility library for the Franz Framework. |
|
|
Franz.Common.Messaging.EntityFramework
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 77 | 11/10/2026 |
| 2.3.4 | 360 | 11/1/2026 |
| 2.3.3 | 330 | 10/28/2026 |
| 2.3.2 | 124 | 10/27/2026 |
| 2.3.1 | 178 | 10/26/2026 |
| 2.3.0 | 245 | 7/21/2026 |
| 2.2.19 | 143 | 7/19/2026 |
| 2.2.18 | 156 | 7/19/2026 |
| 2.2.17 | 650 | 7/12/2026 |
| 2.2.16 | 152 | 7/2/2026 |
| 2.2.15 | 170 | 6/29/2026 |
| 2.2.14 | 157 | 6/29/2026 |
| 2.2.13 | 164 | 6/29/2026 |
| 2.2.12 | 157 | 6/28/2026 |
| 2.2.11 | 159 | 6/28/2026 |
| 2.2.10 | 164 | 6/28/2026 |
| 2.2.9 | 162 | 6/28/2026 |
| 2.2.8 | 160 | 6/28/2026 |
| 2.2.7 | 162 | 6/7/2026 |
| 2.2.6 | 157 | 6/6/2026 |