RavenMigrations 3.0.0

.NET Core 2.1
There is a newer version of this package available.
See the version list below for details.
Install-Package RavenMigrations -Version 3.0.0
dotnet add package RavenMigrations --version 3.0.0
<PackageReference Include="RavenMigrations" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RavenMigrations --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RavenMigrations, 3.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install RavenMigrations as a Cake Addin
#addin nuget:?package=RavenMigrations&version=3.0.0

// Install RavenMigrations as a Cake Tool
#tool nuget:?package=RavenMigrations&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Raven Migrations

Join the chat at https://gitter.im/migrating-ravens/RavenMigrations

Build status

Quick Start

    PM > Install-Package RavenDB.Migrations


Raven Migrations is a migration framework for RavenDB to help with common tasks you might have to do over time to your database. The framework API is heavily influenced by Fluent Migrator.


We believe any changes to your domain should be visible in your code and reflected as such. Changing things "on the fly", can lead to issues, where as migrations can be tested and throughly vetted before being exposed into your production environment. With RavenDB testing migrations is super simple since RavenDB supports in memory databases (our test suite is in memory).

This is important, once a migration is in your production environment, NEVER EVER modify it in your code. Treat a migration like a historical record of changes.


Every migration has several elements you need to be aware of. Additionally, there are over arching concepts that will help you structure your project to take advantage of this library.

A Migration

A migration looks like the following:

// #1 - specify the migration number
public class First_Migration : Migration // #2 inherit from Migration
    // #3 Do the migration
    public override void Up()
        using (var session = DocumentStore.OpenSession())
            session.Store(new TestDocument 
                Id = "TestDocuments/1",
                Name = "Khalid Abuhakmeh" 
    // #4 optional: undo the migration
    public override void Down()
        using (var session = DocumentStore.OpenSession())

To run the migrations, you can use Microsoft's Dependency Injection:

public void ConfigureServices(IServiceCollection services)
    // Add the MigrationRunner into the dependency injection container.

    // ...
    // Get the migration runner and execute pending migrations.
    var migrationRunner = services.BuildServiceProvider().GetRequiredService<MigrationRunner>();

Not using ASP.NET Core? You can create the runner manually:

// Skip dependency injection and run the migrations.

// Create migration options, using all Migration objects found in the current assembly.
var options = new MigrationOptions();

// Create a new migration runner. docStore is your RavenDB IDocumentStore. Logger is an ILogger<MigrationRunner>.
var migrationRunner = new MigrationRunner(docStore, options, logger);

Full documentation and sample project available on the GitHub repo.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.0.1 2,182 3/21/2022
5.0.0 24,257 7/26/2020
4.3.0 6,589 5/4/2020
4.1.7 25,773 1/21/2019
4.1.6 518 1/18/2019
4.1.4 516 1/4/2019
4.1.3 485 1/3/2019
4.1.2 548 11/27/2018
4.1.1 841 10/23/2018
4.1.0 565 10/9/2018
4.0.0 594 9/17/2018
3.0.0 650 7/19/2018
2.1.0 14,250 6/20/2016
2.0.0 2,265 1/22/2016
1.2.0 7,573 5/20/2015
1.1.0 786 5/18/2015
1.0.1 1,605 7/10/2014
1.0.0 1,000 10/28/2013

Upgrade to Raven 4, .NET Core 2.1.