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

Fix for 8332. Pass in arguments to IDesignTimeDbContextFactory #20341

Merged
merged 1 commit into from
Apr 25, 2020

Conversation

lajones
Copy link
Contributor

@lajones lajones commented Mar 19, 2020

Fixes #8332

This updates the dotnet-ef, ef and PowerTools to pass in the arguments

@lajones lajones requested a review from bricelam March 19, 2020 01:55
@lajones lajones self-assigned this Mar 19, 2020
@smitpatel
Copy link
Member

Incorrect issue linked?

@lajones
Copy link
Contributor Author

lajones commented Mar 19, 2020

@smitpatel Fixed.

Copy link
Contributor

@bricelam bricelam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you manually verify that this works? You can install a local build of dotnet-ef using the following command:

build -pack
dotnet tool install -g dotnet-ef --version 5.0.0-* --add-source C:\path\to\efcore\artifacts\packages\Debug\Shipping

Things to test: (manually is fine)

  • Does it work with short and long options unknown to ef? (e.g. -u and --unknown)
    • If not, do they work with --? (e.g. dotnet ef dbcontext info -- --unknown)
  • Are arguments passed into Program.BuildWebHost/CreateWebHostBuilder/CreateHostBuilder?
  • Are the arguments passed into IDesignTimeDbContextFactory.Create?

src/ef/Commands/DatabaseDropCommand.cs Outdated Show resolved Hide resolved
test/EFCore.Design.Tests/Design/DbContextActivatorTest.cs Outdated Show resolved Hide resolved
@lajones
Copy link
Contributor Author

lajones commented Mar 24, 2020

Just note to myself: to install the tool for test you need to run:

build -pack
dotnet tool install -g dotnet-ef --version 5.0.0-dev --add-source C:\path\to\efcore\artifacts\packages\Debug\Shipping

5.0.0-* picks up a different version.

@lajones
Copy link
Contributor Author

lajones commented Mar 25, 2020

@bricelam I've determined that though the above is installing the dotnet-ef and ef tools, it appears to be picking up it's copy of Microsoft.EntityFrameworkCore.Design.5.0.0-dev.nupkg from somewhere else i.e. the tool reflects the changes I've made to the dotnet-ef and ef projects - but not to the EFCore.Design project - even though the Microsoft.EntityFrameworkCore.Design.5.0.0-dev.nupkg is updated and is available in the path I pass to --add-source. Any ideas on how to fix this so I can test?

@lajones
Copy link
Contributor Author

lajones commented Mar 25, 2020

@bricelam Never mind. I cleared my NuGet caches and a warning message showed up saying it was picking up an old version. If I then added the path from --add-source as one of the Package Sources for the target app, then it picked up the correct version of Microsoft.EntityFrameworkCore.Design.5.0.0-dev.nupkg during build.

@lajones
Copy link
Contributor Author

lajones commented Mar 26, 2020

@bricelam I've now manually verified that this works. If you pass the -v flag to any command you'll now see a Remaining arguments output which lists the arguments being passed into each command. DatabaseOperations, DbContextOperations and MigrationsOperations now all have access to a _args variable which is filled in with any remaining arguments.

@lajones lajones changed the title Partial fix for 8332. Fix for 8332. Pass in arguments to IDesignTimeDbContextFactory Mar 26, 2020
@lajones
Copy link
Contributor Author

lajones commented Mar 26, 2020

@bricelam Also added the Powershell updates after testing those too.

@lajones lajones requested a review from bricelam March 31, 2020 16:05
Copy link
Contributor

@bricelam bricelam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor comments

@lajones lajones merged commit c3f5041 into master Apr 25, 2020
@lajones lajones deleted the 20200318_Issue8332_01 branch April 25, 2020 04:48

// TODO: Flow in from tools (issue #8332)
_designArgs = Array.Empty<string>();
_designArgs = (string[])args["remainingArguments"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should coalesce to empty array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tools: Flow arguments into IDesignTimeDbContextFactory
4 participants