Does anyone know how to change the output directory of the following command?
dotnet ef migrations add Initial --context EsportshubApi.Models.ApplicationDbContext
I tried to add the option:
But that doesn't do anything. There is a
--data-dir option as well and something else with directory. But none of them is the output for migrations.
My problem is that I have 2 DbContexts so I want their migrations to be separated.
dotnet ef migrations add Initial --context EsportshubApi.Models.ApplicationDbContext -o YourFolderPath
dotnet ef migrations add
Adds a new migration.
< NAME > The name of the migration.
-o --output-dir < PATH > The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to "Migrations".
Package Manager Console run this command:
PM> Add-Migration 001 -OutputDir "Data/Migrations"
My structure is:
.AspCoreProject -Data -Migrations 20190721162938_001.cs MainDbContextModelSnapshot.cs
For removing last migration use:
Note: If the migration is already applied to the database, then you will get this error:
The migration '20190721162938_001' has already been applied to the database. Revert it and try again. If the migration has been applied to other databases, consider reverting its changes using a new migration.
PM> Remove-Migration -Force