dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.73k stars 3.17k forks source link

Add --connection parameter for Remove-Migration #24271

Open coreyfournier opened 3 years ago

coreyfournier commented 3 years ago

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. I have multiple projects, but a single .net core library contains the DbContext and migration files. This all works fine where I am able to specify the Context, Project, and Connection. Except for "Remove-Migration". It doesn't allow the parameter Connection. Because of this I have to default a connection in the DbContext.

Describe the solution you'd like

I would like to be able to specify the Connection like all other functions support in the Remove-Migration function

jikuja commented 3 years ago

Because #25252 was marked as duplicate of this:

dotnet ef migrations remove help documentation should be improved:

Revert the migration if it has been applied to the database. does not give any hint to user that argument is also used to ignore connection related issues.

lauxjpn commented 2 years ago

I second this issue. This always catches me cold once in a while when I just want to remove a migration and suddenly my database is being hit.

The default for dotnet ef migrations remove needs to not hit any database. An optional parameter to also change the database could be considered, but technically this is already covered by the dotnet ef database update command.

Generally, I think that only the dotnet ef database commands should be able to change a database.

chrisfcarroll commented 2 years ago

This is currently awful :-(

Sanity imho would be one of:

ska737 commented 1 year ago

The default for dotnet ef migrations remove needs to not hit any database.

This has gotten me a lot. I'm setting up the migrations before applying them (I'm migrating a project and am just trying to get the table definitions to match, not actually creating the database). I don't want to create the database just so I can remove the last migration that was not correct.

Generally, I think that only the dotnet ef database commands should be able to change a database.

This makes total sense. The only things that should even attempt to hit a database are the dotnet ef database commands. Everything else should be segregated.

dhtek commented 8 months ago

+1, this makes total sense ! We should be able to remove migration without database and doing the database update using the command dotnet ef database

Erumer commented 7 months ago

I completely agree: having migrations command act on code, and database on db would be much more clear

stormbreakermerika commented 2 months ago

Yep this would be nice to know. Just ran into this situation and had to go looking for dotnet ef migrations remove --force

Upvote from me on this issue