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 ef migrations has-pending-model-changes should honour the --project argument #35637

Open
stevecwilkinson opened this issue Feb 13, 2025 · 1 comment

Comments

@stevecwilkinson
Copy link

What problem are you trying to solve?

The dotnet ef migrations has-pending-model-changes command is a great recent addition (thanks!) but it does not appear to honour the --project flag.

This is a problem for developers needing to use separate migration assemblies (as per https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/providers, using a single DbContext). The following works nicely:

dotnet ef migrations add Migration_1 --project ..\migrations\SqlServer\SqlServer.csproj -- SqlServer

(where SqlServer.csproj is the target migration assembly, and the -- SqlServer is passing 'SqlServer' as an argument to the code that creates the DbContext. I have a similar line with the Postgres in place of SqlServer.)

but the following doesn't:

dotnet ef migrations has-pending-model-changes --project ..\migrations\SqlServer\SqlServer.csproj -- SqlServer

Instead of checking the migration assembly specified, the check for up-to-date migrations appears to be made in the assembly that contains the DbContext definition.

(I umm'd and ahh'd about raising this as a bug report but as it is a relatively new feature which was a pleasant surprise to find implemented, it seemed a bit of a heavyweight approach. Happy to re-raise as a bug if that would be better.)

Describe the solution you'd like

This may not be deemed a high priority issue as possible separate migration assemblies aren't being widely used. It would be good to see it added to the backlog, but meanwhile, if some sample code could be provided that maybe re-uses the existing implementation but with separate migration assembly support, that would splendid.

MTIA.

@stevecwilkinson
Copy link
Author

I've just hit the same issue for dotnet ef migrations script - this could be a real show-stopper. The documentation (which everyone seems to apologise for, indicates that the "common options" (including --project) apply to the script command...

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

1 participant