Stores NServiceBus data in various relational database engines, without the need for an intermediate ORM, using only a configured DbConnection
.
Persistence at a glance
For a description of each feature, see the persistence at a glance legend.
Feature | |
---|---|
Storage Types | Sagas, Outbox, Subscriptions, Timeouts |
Transactions | Local database transactions or distributed transactions when available |
Concurrency control | Optimistic concurrency for correctness + pessimistic concurrency for performance |
Scripted deployment | SQL scripts generated at compile time, can be promoted outside build directory. |
Installers | Installers execute the generated scripts, which can be enabled in development. |
Highlights
- Supports multiple database engines.
- No ORM dependency: can be used with Entity Framework, Dapper, etc.
- Independent tables for each endpoint. No "noisy neighbor" problems.
- Generates DDL scripts at compile time in the build output directory.
- Generated scripts can be promoted outside the build directory and:
- Added to source control.
- Compared using a diff viewer.
- Inspected by DBAs.
- Treated as first-class citizens in operations workflows for installation and deployment.
- Sagas are:
- Stored using Json.NET to serialize complex data structures, with no need to manage complex table structures.
- Built to be version-aware with support for data evolution.
- Built to allow changing the
CorrelationId
over time.
Supported SQL implementations
NuGet Packages
Script creation
SQL installation scripts are created as a compile-time output alongside a project's binary outputs. Additionally, these scripts can be promoted to a directory under source control so that differences can be easily tracked and analyzed. To learn more, see Controlling Script Generation.
The scripts are generated by an MSBuild task at compile time. Any project containing either endpoint configuration or sagas must directly reference the SQL Persistence package. If endpoint configuration and sagas are contained in seperate projects, both projects must directly reference the SQL Persistence package and include the
assembly: SqlPersistenceSettings
attribute.