Changing Entity Framework Core Migrations Folder

Want your Entity Framework Core migrations to land in a folder other than the default Migrations folder? Here's how to fix that.

By default, Entity Framework Core migrations will put your migration code inside of a Migrations folder in the root of your project. This isn't always desirable, but luckily changing the output folder is easy. All you need to do is specify the option -o followed by the desired path. The example below will output migration code into the Migrations folder located within the Model folder.

dotnet ef migrations add Initial -o Model\Migrations
Example of -o usage

Note that you'll only need to specify the output argument for the first migration. Entity Framework Core is smart enough to put future migrations in the correct folder.