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

Add support for using response files from EF commands #10409

Closed
ajcvickers opened this issue Nov 27, 2017 · 6 comments
Closed

Add support for using response files from EF commands #10409

ajcvickers opened this issue Nov 27, 2017 · 6 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. good first issue This issue should be relatively straightforward to fix. help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. type-enhancement
Milestone

Comments

@ajcvickers
Copy link
Member

To make something like this work:

dotnet ef migrations add @MyContext.ef.config
@ajcvickers ajcvickers added this to the Backlog milestone Nov 27, 2017
@ajcvickers ajcvickers added type-enhancement help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. labels Nov 27, 2017
@bricelam
Copy link
Contributor

bricelam commented Nov 27, 2017

Should be as simple as setting command.HandleResponseFiles = true in src\ef\Commands\CommandBase.cs and testing that it all works as expected.

@joacar
Copy link

joacar commented Nov 28, 2017

Hi,

Before I get started with this (I've no development experience with EF Core it self, so probably some stupid questions initially) I have some questions

  1. Are there any file structure outlined
  2. One file for all context or one per context
  3. Where should we look for the response file
  4. Default file if no context is specified

My thought is that the response file just acts as a argument container for the given context. We have MyContext.ef.config with the content -p ..\A\A.csproj -o ..\B\Migrations then executing dotnet ef migrations add Initial -c MyContext is dotnet ef migrations add Initial -c MyContext -p ..\A\A.csproj -o ..\B\Migrations.

If no context is specified when excuting the command then the default file must start with (or contain) the argument -c.

Additional parameters are appended to the command as expected and if a parameter is specified twice then the explicit parameter takes precedence over the parameter defined in the file.

  • Architecture
  • Tests
  • Code
  • Document

@bricelam
Copy link
Contributor

bricelam commented Nov 29, 2017

Response files are a general feature of the command-line argument parser. We'd simply turn it on for the dotnet ef commands.

The feature lets you read command-line arguments from a file. For example, if ECHO supported it (it doesn't), you could do this to print out the contents of message.txt.

ECHO @message.txt

dotnet ef would never automatically load one of these files. You'd always have to specify it. To use this feature as you originally requested it, you'd have to put each context in its own file.

@jsacapdev
Copy link
Contributor

@bricelam this is a feature that i would find useful and so i have had a go with the changes and it works as you explained. do you have any guidance on unit testing?

For me I created a project and at the command line ran something like dotnet ./dotnet-ef.dll migrations list @BloggingContext.ef.config. Because the entry point is calling the command line, I am unsure on your preferred approach as to how to achieve this in an automated way (is there an expectation for automated testing at the command line level)? Or is it sufficient for the entry point to just test CommandLineApplication::ExpandResponseFiles().

If you do have any further thoughts and/or guidance on how to approach the unit testing that would be appreciated.

@bricelam
Copy link
Contributor

bricelam commented Dec 12, 2017

I think we can sort out adding automated tests as part of #9111. If you've manually verified it all works, go ahead and submit the PR.

@bricelam bricelam self-assigned this Dec 19, 2017
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Dec 19, 2017
bricelam pushed a commit that referenced this issue Dec 19, 2017
- Enable response files at command line

Manual tests include:

1. dotnet ./dotnet-ef.dll migrations add initial @BloggingContext.ef.config

(BloggingContext.ef.config contents)
-p
C:\playground\AppToBuilder\AppToBuilder.csproj
-s
C:\playground\AppToBuilder\AppToBuilder.csproj

2. dotnet ./dotnet-ef.dll @BloggingContext.ef.config

(BloggingContext.ef.config contents)
migrations
add
initial
-p
C:\playground\AppToBuilder\AppToBuilder.csproj
-s
C:\playground\AppToBuilder\AppToBuilder.csproj

3. dotnet ./dotnet-ef.dll migrations add initial @d:/BloggingContext.ef.config (relative path)

4. dotnet ./dotnet-ef.dll migrations add @d:/BloggingContext.ef.config (error condition, results in Missing required argument '<NAME>'.)

Fixes #10409
@bricelam bricelam modified the milestones: Backlog, 2.1.0 Dec 19, 2017
@joacar
Copy link

joacar commented Apr 16, 2018

For those waiting and want a temporary solution here is what I've used mean while

Add-Migration

@echo off
set /p args=<%2

pushd %~dp0src\WebApp

echo on
dotnet ef migrations add %1 %2

@echo off
popd %~dp0

Similarly for Remove-Migration and Update-Database.

@bricelam bricelam added the good first issue This issue should be relatively straightforward to fix. label May 31, 2019
@ajcvickers ajcvickers modified the milestones: 2.1.0-preview1, 2.1.0 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. good first issue This issue should be relatively straightforward to fix. help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. type-enhancement
Projects
None yet
Development

No branches or pull requests

4 participants