Skip to content
github-actions[bot] edited this page Nov 17, 2026 · 2 revisions

Database migrations for MongoDB in .NET. Write migrations in C# with the official MongoDB C# driver, declare what your collections should look like, and apply both from the command line, your build server or your application.

Note

These pages are published from the wiki/ folder on main. To fix or improve them, open a pull request there; edits made in the wiki itself are overwritten.

New here?

  1. Installation: install the migrate-mongo tool.
  2. Getting Started: from nothing to an applied, inspected and rolled-back migration against a local MongoDB.
  3. Project Setup: init, the dotnet new templates and using an existing project.

I want to...

Write migrations Keep collections in line Deploy and connect
Write a migration Declare collections Use per-environment config and secrets
Use transactions Manage indexes Run in CI
Record what a migration did Manage Atlas Search indexes Build once, deploy many with bundles
Inject services into migrations Set collection options Run in Docker
Customise the create template Add a $jsonSchema validator Run from my application
Adopt an existing database Declare views Tunnel through an SSH bastion
Fix a failed run Clean up undeclared collections Use AWS IAM authentication

Look something up

Understand how it works

Requirements

  • A .NET SDK, 10 or later, to build your migrations project. Running the tool or a bundle doesn't need .NET.
  • MongoDB.Driver 3.9 or later in your migrations project.
  • MongoDB 5.0 or later. Transactions need a replica set or sharded cluster.

Clone this wiki locally