Reputation: 67193
Does anyone know how the location of the migrations folder is determined.
I added my data folders after the fact. But now I've ended up with this:
The Data\Migrations folder is where I'd like my migrations to go. But, as you can see, they're going in the Migrations folder off of the root.
Upvotes: 2
Views: 2823
Reputation: 205629
The migrations folder of the add migration commands is determined by the respective output directory argument of the command (--output-dir
or -o
for CLI dotnet ef migrations add
and -OutputDir
for PMC Add-Migration
). And as explained in the documentation of the both commands:
The directory use to output the files. Paths are relative to the target project directory. Defaults to "Migrations".
So you have to provide that parameter, for instance
Add-Migration SomeMigration -OutputDir Data\Migrations
Note that this would also change the migrations classes namespace.
Now, the cool thing not mentioned in the documentation is that you have to do that only once, because the next add migration commands actually default to the last migration folder.
With that being said, the best is to specify this for the very first migration you are adding.
In case you want to modify the existing project with already added migrations like shown in the question, then manually move the whole root "Migrations" folder to "Data", then optionally change the namespace of all .cs
files inside (including the .designer.cs
) to namespace {RootNamespace}.Data.Migrations
, and you are done. The next migrations will be added there without the need of specifying the folder.
Upvotes: 5