Skip to content

Inconsistent "Migrations" folder path when Re-Scaffold #1675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stevesiu opened this issue Jul 16, 2016 · 4 comments
Closed

Inconsistent "Migrations" folder path when Re-Scaffold #1675

stevesiu opened this issue Jul 16, 2016 · 4 comments

Comments

@stevesiu
Copy link

Re-Scaffold migrations created "Migrations" folder in project root instead of the original path /Data/Migrations. It still works but a consistent folder path is better.

Steps to reproduce the issue

  1. Create an "ASP.NET Core Web Application (.NET Core) with "Individual User Accounts" authentication
  2. Delete the "/Data/Migrations" folder
  3. Run "Add-Migration MyDB" in Package Manager Console
  4. The "Migrations" folder is created in the project root instead of "/Data"
@rondefreitas
Copy link

rondefreitas commented Jul 16, 2016

Migrations will be placed in whatever folder the Model Snapshot file is located in, but the default if none yet exist is Migrations. Since they included a snapshot file in Data/Migrations in the new templates, it scaffolds additional migrations there.

They should probably change the default to match the templates.

In the meantime, a workaround does exist... one of the parameters for the migration add command includes specifying the path.

From the ef docs:

Usage: dotnet ef migrations add [arguments] [options]

Arguments:
  [name]  The name of the migration

Options:
  -o|--output-dir <path>          The directory (and sub-namespace) to use. If omitted, "Migrations" is used. Relative paths are relative the directory in which the command is executed.
  -c|--context <context>          The DbContext to use. If omitted, the default DbContext is used
  -e|--environment <environment>  The environment to use. If omitted, "Development" is used.
  --json                          Use json output. JSON is wrapped by '//BEGIN' and '//END'
  -h|--help                       Show help information
  -v|--verbose                    Enable verbose output

To run your intended migration with your output going to the Data/Migrations folder, you'd do the following:

dotnet ef migrations add InitialMigration -o Data/Migrations

@stevesiu
Copy link
Author

@Rdefreitas, thanks for the explanation and workaround!

@rondefreitas
Copy link

@stevesiu glad it worked out for you :)

@aspnet-hello
Copy link

This issue is being closed because it has not been updated in 3 months.

We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants