VivaVictoria.Chaos 1.1.1

.NET Core 3.1
dotnet add package VivaVictoria.Chaos --version 1.1.1
NuGet\Install-Package VivaVictoria.Chaos -Version 1.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VivaVictoria.Chaos" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VivaVictoria.Chaos --version 1.1.1
#r "nuget: VivaVictoria.Chaos, 1.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install VivaVictoria.Chaos as a Cake Addin
#addin nuget:?package=VivaVictoria.Chaos&version=1.1.1

// Install VivaVictoria.Chaos as a Cake Tool
#tool nuget:?package=VivaVictoria.Chaos&version=1.1.1


Universal version migration tool for .NET


version 1.0.0-preview - unstable

Supported platforms:

  • .NET Core 3.1
  • .NET 5+


Chaos is simple database-independent migration tool. Independence from the DBMS and the connection method is achieved due to the following mechanism:
base tool class is Chaos, it manages process of migration and requires next components:

  • ILogger for logging actions and SQL statements,
  • IMigrator for receiving / saving metadata and applying migration scripts,
  • IMigrationReader for reading list of migrations stored in MigrationInfo model.

In turn, some IMigrator or IMigrationReader implementations can be dependent on ISettings instance. ISettings provides ConnectionString and default MigrationMode.
MigrationMode is enum describing the migration mode:

  • Default - default mode from ISettings
  • One - run each migration and save metadata in one migration,
  • None - do not use migrations.
    Note: MigrationMode is just recommendation and will be used only if IMigrator and DBMS supports specified mode.


Simple example with PostgreSQL, ConsoleLogger and Reflection reader:

var services = new ServiceCollection()

//register settings
services.AddTransient<ISettings, Settings>();
//register PostgreSQL or other RDBMS driver
//register ConsoleLogger or other ILogger
//add Reflection support with project Assembly

Now you can request IChaos service and run migrations.

//build chaos via DI container            
using (var scope = services.BuildServiceProvider())
    var chaos = scope.GetRequiredService<IChaos>();

Data Race on replicated services


Let's imagine a situation in which our service is implemented in a Docker container with replication.
In most cases, one of the replicas will start before the others and perform migrations. However, there may be cases when replicas are started simultaneously, or the migration process is too long and several replicas have time to start the migration. In this case, all replicas will receive an error due to the race condition.

Usual solution

Usual solution is running migration as a part of CI/CD pipeline - your CI/CD tool runs migration and then, if database migrated successfully, containers will be updated.

Chaos solution

Chaos provides you possibility to skip migrations if some condition is not met:

using (var scope = services.BuildServiceProvider())
        .Init(() => !string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("REPLICA_MASTER")))

Now, define environment variable REPLICA_MASTER only on your master replica container. All other replicas will be skipped.
Note: it is not ideal solution, because some of your replicas can be available before database will be migrated and some requests to database may be failed. But if you use blue-green deploy with 'usual' solution you can receive same errors when blue container is still exists and green container runs migrations. Blue container can fail on database requests.

Total nuget packages list



  1. If you creates new project, please follow the following structure:
  • Extensions - all static classes with extension methods
  • Interfaces - for public project interfaces
  • Models - for all models
  • Enums - for all enums
  • Service implementations and should be placed in project root
  1. Please, throw Exceptions only if you receive fatal error and need to abort migration process.
  2. Support readme actuality and create samples for new projects.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (12)

Showing the top 5 NuGet packages that depend on VivaVictoria.Chaos:

Package Downloads

Package Description


Migrator for Chaos tool based on Dapper library. Supports any ADO driver by using IDbConnection from IConnectionProvider.


MS SqlServer Migrator for Chaos tool. Based on Chaos.Dapper and System.Data.SqlClient.


ClickHouse Migrator for Chaos tool. Based on Chaos.Dapper and ClickHouse.Ado.


Raw sql migration files loader.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 1,245 10/17/2021
1.1.1-preview 633 10/7/2021
1.1.0 1,123 10/7/2021
1.0.1-preview 363 9/25/2021
1.0.0-preview 439 9/25/2021