Skip to content
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

dotnet migrations add with --namespace issue #21443

Open
Tracked by #22945
Tommigun1980 opened this issue Jun 29, 2020 · 2 comments
Open
Tracked by #22945

dotnet migrations add with --namespace issue #21443

Tommigun1980 opened this issue Jun 29, 2020 · 2 comments

Comments

@Tommigun1980
Copy link

Tommigun1980 commented Jun 29, 2020

Hi.

I have a project with several "sets" of migrations, i.e. one migration "set" per distribution type (development, staging, production), as these databases can be in different stages of development and use different database providers (SQLite for local server, Azure SQL for others, etc).

I have solved this by making shell scripts that take in the environment and ultimate runs something like:

dotnet ef migrations add MigrationName --namespace=MyProject.MobileAppService.Migrations.Development --output-dir Migrations/Development --context ContextName

dotnet ef database update --namespace=MyProject.MobileAppService.Migrations.Development --context ContextName

This creates one folder in my project per environment, and allows me to have separate "migration tracks" if you will. All of this works fine, except "dotnet ef migrations add", even when specifying a --namespace, doesn't fully work. It seems to read from the first migration file it encounters and only uses --namespace for the output. This forces me to temporarily delete all migration folders except the one I want to add to when running the "dotnet migrations add" command.

So TLDR: "dotnet migrations add" uses --namespace only for output and not also for input. (dotnet ef database update works properly when --namespace is provided, so it is only the adding operation which doesn't fully work with --namespace).

Further technical details

EF Core version: 5.0.0-preview.6.20312.4
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer): SQLite/Azure SQL Server
Target framework: (e.g. .NET Core 3.0): .NET Core 3.1
Operating system: macOS
IDE: (e.g. Visual Studio 2019 16.3): VS For Mac 8.6.5 (build 23)

Tangentially related feature request: #21444

@ajcvickers
Copy link
Member

@Tommigun1980 Honestly, we didn't think of using --namespace in this way, but it does make sense.

@ajcvickers
Copy link
Member

Related to #32738

@ajcvickers ajcvickers removed their assignment Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants