.NET library


In a .NET project, the easiest way to keep the database schema up to date across all your environments, is to deploy the SQL migration scripts with your assemblies and to execute Evolve at startup. This way, the deployed application automatically applies migrations and is always in sync with the database schema version.

Note you can even embed your migration scripts into assemblies not to expose intrisics of your application to the outside (see EmbeddedResourceAssemblies option).


Evolve is available on NuGet.

Install-Package Evolve

Quick Start

Initialize and configure Evolve to migrate the schema to the latest version when you start your application:

    var cnx = new SqliteConnection(Configuration.GetConnectionString("MyDatabase"));
    var evolve = new Evolve.Evolve(cnx, msg => _logger.LogInformation(msg))
        Locations = new[] { "db/migrations" },
        IsEraseDisabled = true,

catch (Exception ex)
    _logger.LogCritical("Database migration failed.", ex);

Create at least one folder at the root of your project for your migration scripts and named them following the pattern described here. For example: V1_3_1_1__Create_table.sql

Make sure to set the property Copy to output directory to Copy always on each of your migration script, or modify your csproj file to automatically copy all the SQL files to the output build folder:

  <Content Include="db\migrations\**\*.sql">

Samples can be found here