SQL Persistence

NuGet Package NServiceBus.Persistence.Sql (6.x)
Target NServiceBus Version: 7.x

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.

Storage TypesSagas, Outbox, Subscriptions, Timeouts
TransactionsLocal database transactions or distributed transactions when available
Concurrency controlOptimistic concurrency for correctness + pessimistic concurrency for performance
Scripted deploymentSQL scripts generated at compile time, can be promoted outside build directory.
InstallersInstallers execute the generated scripts, which can be enabled in development.


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.


Related Articles

Last modified