Skip to content

Command create

github-actions[bot] edited this page Nov 17, 2026 · 1 revision

Creates a new migration file. Tool only. It only reads project and migrationTemplate from the config, so it works without connection variables set.

migrate-mongo create <name> [--minimal]
$ migrate-mongo create AddEmailIndexToUsers
Created src/MyApp.Migrations/Migrations/M20261014164028_AddEmailIndexToUsers.cs

Arguments and options

Meaning
<name> The migration's name in PascalCase, e.g. AddEmailIndexToUsers. It becomes the class name, and in kebab-case (add-email-index-to-users) the migration's name.
--minimal Write bare UpAsync and DownAsync methods, without the commented results and tracking examples. Ignores migrationTemplate.

What it writes

The file goes in the project's Migrations folder, as M<id>_<Name>.cs, in the <project root namespace>.Migrations namespace. The id is the current UTC time (yyyyMMddHHmmss); if a migration already has that id, it steps forward a second.

With migrationTemplate set, that file is used instead of the built-in template. See Custom Templates.

See also

Clone this wiki locally