Cobytelabs.Modulus.Data.SqlServer
1.3.0
dotnet add package Cobytelabs.Modulus.Data.SqlServer --version 1.3.0
NuGet\Install-Package Cobytelabs.Modulus.Data.SqlServer -Version 1.3.0
<PackageReference Include="Cobytelabs.Modulus.Data.SqlServer" Version="1.3.0" />
<PackageVersion Include="Cobytelabs.Modulus.Data.SqlServer" Version="1.3.0" />
<PackageReference Include="Cobytelabs.Modulus.Data.SqlServer" />
paket add Cobytelabs.Modulus.Data.SqlServer --version 1.3.0
#r "nuget: Cobytelabs.Modulus.Data.SqlServer, 1.3.0"
#:package Cobytelabs.Modulus.Data.SqlServer@1.3.0
#addin nuget:?package=Cobytelabs.Modulus.Data.SqlServer&version=1.3.0
#tool nuget:?package=Cobytelabs.Modulus.Data.SqlServer&version=1.3.0
Modulus Framework
An enterprise-grade modular monolith framework for .NET 10, built with an
ABP-style [DependsOn] module system, CLI scaffolding, a transactional outbox/inbox,
and first-class multi-tenancy.
Overview
Modulus is designed for teams who need the architectural rigour of ABP or eShop
without the heavyweight abstractions. It provides proven building blocks that
compose cleanly — pick only what your application needs. The framework ships as
31 focused NuGet packages (published as Cobytelabs.Modulus.*) plus a
dotnet tool CLI for scaffolding complete solutions, modules, and CRUD code.
Solution layout
src/ 31 projects across:
core/ Modulus.Core (abstractions+impl merged), Modulus.AspNetCore,
Modulus.AspNetCore.Redis (Redis-backed idempotency store)
data/ Modulus.Data.Abstractions, Modulus.EntityFrameworkCore,
EF Core providers (SqlServer, PostgreSQL, MySQL, SQLite, MongoDB)
identity/ Modulus.Identity (OpenIddict server + 6 IdP adapters +
EF Core mapping merged into one package)
messaging/ Modulus.Events (abstractions merged), Modulus.Mediator
(abstractions merged), Modulus.Inbox (+ MongoDB), Modulus.Outbox,
Modulus.Outbox.Abstractions (kept — circular-dep seam),
Outbox.MongoDB, EventBus.RabbitMQ, EventBus.Kafka,
Modulus.Sagas (Rebus-based)
platform/ Modulus.Platform (MultiTenancy + Authorization +
BackgroundJobs + in-memory Caching + local Storage +
in-process SignalR — NO heavy cloud SDKs), cloud providers
opt-in: Storage.S3, Storage.AzureBlobs, Caching.Redis,
SignalR.Backplane, MultiTenancy.EntityFrameworkCore,
Authorization.EntityFrameworkCore + Authorization.Management
(EF grant store + management API)
observability/ Modulus.Observability (Diagnostics + OpenTelemetry merged)
testing/ Modulus.Testing (WebApplicationFactory-based integration harness)
cli/ Modulus.Cli (Spectre.Console.Cli scaffolding tool)
tests/ 16 projects
unit/ xUnit + NSubstitute + FluentAssertions
integration/ xUnit + Testcontainers (Docker required)
Getting started
Prerequisites
- .NET SDK 10.0.109 or newer (
dotnet --version) - Docker (only for the Testcontainers-based integration tests)
Create a new application
The Cobytelabs.Modulus.* packages aren't on nuget.org yet, so pack the local
feed first, then install the CLI tool and scaffold a complete modular-monolith
solution:
# Pack and install the CLI tool
dotnet pack modulus.slnx -c Release
dotnet tool install -g --add-source ./nupkg Cobytelabs.Modulus.Cli
# Generate a new application (SQLite by default) and run it
modulus app MyApp
cd MyApp
dotnet restore
dotnet run --project src/API/MyApp.Api
CLI commands
The modulus CLI (Spectre.Console.Cli + Scriban) is a dotnet tool that
generates complete solutions, modules, commands, queries, and CRUD code:
| Command | Description |
|---|---|
modulus app <name> |
Creates a modular-monolith solution (Host + Shared kernel + example module + tests) |
modulus module <name> |
Creates a blank 4-layer business module |
modulus add-module <name> |
Adds a module to an existing app + wires [DependsOn] + ProjectReference |
modulus generate-crud <Entity> --module M |
Generates entity, repo, DTOs, command/query handlers, controller |
modulus generate-command <Name> --module M |
Generates a single command + handler |
modulus generate-query <Name> --module M |
Generates a single query + handler |
modulus migrate add <Name> |
Scaffolds an EF Core migration in each module's Infrastructure project |
modulus migrate update |
Applies pending migrations to each module's database |
Each generated module uses a 4-layer Clean-Architecture layout
({App}.Modules.{Module}.{Domain,Application,Infrastructure,Presentation}) with
a per-module DbContext, per-module IUnitOfWork, and DTOs/integration events
living under Application/Dtos and Application/IntegrationEvents.
Templates are embedded Scriban resources under cli/Templates/.
Sample application
samples/ProcureFlow— a reference application (API host + Users module) showing the framework's recommended shape: module system, CQRS viaModulus.Mediator, per-module EF Core persistence, Serilog, Sentry, and forwarded-headers hardening. Ships aNuGet.configpointing at the repo's localnupkg/feed, so it builds straight afterdotnet pack modulus.slnx -c Release.
Module system
Modules implement IModule or inherit from ModulusModule. Dependencies are
declared via [DependsOn(typeof(OtherModule))] attributes (ABP-style).
AddModulus<TStartupModule>(configuration) auto-discovers the full module graph
via topological sort.
[DependsOn(typeof(IdentityModule), typeof(DataModule))]
public sealed class ShopModule : ModulusModule
{
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
// Register module-specific services
}
}
// Program.cs
builder.Services.AddModulus<AppHostModule>(builder.Configuration);
Features
- Modular architecture — ABP-style
[DependsOn]module system with topological-sort discovery andAddModulus<TStartupModule>()wiring. - CQRS mediator —
ICommand<TResult>/IQuery<TResult>with open-generic pipeline behaviors (validation, logging, transaction). No MediatR dependency. - Domain-Driven Design —
AggregateRoot<TId>with domain-event collection,ValueObjectbase, specifications, auditing interfaces. - Transactional outbox — domain events implementing
IIntegrationEventare enqueued to the outbox within the same DB transaction viaModuleDbContext.SaveChangesAsync. A backgroundOutboxProcessorclaims rows atomically, retries with exponential backoff, and dead-letters after max retries. - Inbox dedup — idempotent message processing. All
IIntegrationEventHandler<T>registrations are wrapped with an atomic claim-by-EventId decorator (EF CoreEfInboxStoreor MongoDBMongoInboxStore) so redeliveries don't double-execute. - Multi-tenancy —
ICurrentTenantbacked byAsyncLocal<TenantInfo?>(flows into background jobs / consumers), resolution from header/claim/subdomain, per-tenant connection-string resolver, and soft-delete+tenant query filters onModuleDbContext. - OpenIddict identity — password, client-credentials, and refresh-token grants with deny-by-default credential validation, scope allow-listing, and 6 external IdP adapters (Auth0, Authentik, Azure AD, Duende, Keycloak, Okta) that validate bearer tokens locally via OIDC discovery (signature, issuer, lifetime).
- EF Core providers — SQL Server, PostgreSQL, MySQL, SQLite (EF Core 10), plus MongoDB for document storage.
- Event bus — RabbitMQ (topic exchange, auto-reconnect) and Kafka
(idempotent producer, consumer groups); all implement
IModuleBusand integrate with the outbox. - Sagas — Rebus-based long-running orchestration.
- Platform services — permission-based authorization, background job scheduler (in-memory default; replace with Quartz.NET or Hangfire for production multi-replica deployments), caching (memory, tag-based invalidation), file storage (local, S3, Azure Blob), and SignalR hub base classes.
- API hardening — rate limiting, API versioning, health probes
(
/health/live,/health/ready), CORS, security headers, idempotency keys, feature flags, secrets guard, at-rest PII encryption, forwarded-headers. - Observability — OpenTelemetry tracing wired to the mediator pipeline and module lifecycle; correlation-ID propagation. Add EF Core and HTTP instrumentation via their respective OpenTelemetry packages.
Build
dotnet build modulus.slnx
The solution compiles with 0 errors, 0 warnings (TreatWarningsAsErrors is
enabled globally). Central Package Management is used via
Directory.Packages.props.
Common commands
| Task | Command |
|---|---|
| Build (Debug) | dotnet build modulus.slnx |
| Run all tests | dotnet test modulus.slnx |
| Run unit tests | dotnet test modulus.slnx --filter "Category=Unit" |
| Pack NuGet packages | dotnet pack modulus.slnx -c Release |
| Format check | dotnet format modulus.slnx --verify-no-changes |
Target framework
- .NET 10 (
net10.0) - SDK 10.0.109 or later
License
Apache License 2.0 — see 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
- Cobytelabs.Modulus.EntityFrameworkCore (>= 1.3.0)
- Microsoft.EntityFrameworkCore (>= 10.0.9)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.9)
- Microsoft.EntityFrameworkCore.SqlServer (>= 10.0.9)
- Microsoft.Extensions.Caching.Memory (>= 10.0.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.12.1)
- System.IdentityModel.Tokens.Jwt (>= 8.12.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.