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

Allow namespace in code generated by tools to be specified on the command line #9723

Closed
chassq opened this issue Sep 7, 2017 · 24 comments · Fixed by #20355
Closed

Allow namespace in code generated by tools to be specified on the command line #9723

chassq opened this issue Sep 7, 2017 · 24 comments · Fixed by #20355
Assignees
Labels
area-scaffolding area-tools closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-2.1 type-enhancement
Milestone

Comments

@chassq
Copy link

chassq commented Sep 7, 2017

When using scaffold to write to a relative directory in the project the namespace of the target folder does not seem to be honored. For example:

dotnet ef dbcontext scaffold "Server=localhost\SQLEXPRESS;Database=<dbname>;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -c ApplicationDbContext --force --output-dir ..\lib.dal.sql\models

Note that we are writing to a folder of another project. However the namespace of the files created is that of the project namespace not of the folder. The namespace is in this case lib.dal.sql but should be lib.dal.sql.models

Steps to reproduce

Create a scaffold project but write the output to another directory in another project.

Further technical details

EF Core version: 2.0.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Win 10 latest patches
IDE: Visual Studio 2017 latest patches

@ajcvickers ajcvickers added this to the 2.1.0 milestone Sep 8, 2017
@smitpatel smitpatel removed this from the 2.1.0 milestone Sep 8, 2017
@smitpatel
Copy link
Contributor

Removing milestone as neither migrations nor scaffolding process any namespace when it is outside of your project directory. (not enough data to compute anything). We just use default namespace.

@ajcvickers
Copy link
Contributor

After discussing in triage we are going to close this as by-design. The namespace resolution works correctly when generating to a location inside the project. When generating to locations that step out of the project (with "..\") it becomes ambiguous and error prone, so we just generate using the root namespace.

@chassq
Copy link
Author

chassq commented Sep 12, 2017

Ok, then please add a namespace override to the cmd line args. I assume since scaffold does not support NetStandard (according to the docs I think) we cannot target a NetStandard lib yet.

@smitpatel
Copy link
Contributor

Co-assigned Brice for design.

@ajcvickers
Copy link
Contributor

Note from triage: we will consider allowing the namespace to be specified on the command line. @bricelam to make some proposals.

@ajcvickers ajcvickers changed the title Scaffold namespace of the target folder is not being honored Allow namespace in code generated by tools to be specified on the command line Sep 14, 2017
@ajcvickers ajcvickers added this to the 2.1.0 milestone Sep 14, 2017
@bricelam
Copy link
Contributor

Note, we should do this for both Add-Migration and Scaffold-DbContext.

@ajcvickers
Copy link
Contributor

@darkguy2008 What specifically makes you think this has been done? (It's open and in the 5.0 milestone.)

@darkguy2008
Copy link

darkguy2008 commented Jan 22, 2020

@ajcvickers "We will re-assess the backlog following the 3.0 release and consider this item at that time.".

Unfortunately the priorities, again as I said, are not on the end user's needs. A bug/request that's been open for 3 years is enough proof.

@atrauzzi
Copy link

atrauzzi commented Jan 23, 2020

@ajcvickers - I've pushed a lot of GitHub suggestions in the past for things that don't present as "popular" through GitHub tickets.

The people here aren't going to be fully representative of demand. I think the better argument here is consistency and aligning with the overall direction of Microsoft tools. The lack of a cross platform, command line equivalent here, accompanied by suggestions to use a VS-only workaround is a bit...off, don't you think?

If I wear my PM hat, something tells me that once built, this will be used and very widely appreciated.

@ajcvickers
Copy link
Contributor

@atrauzzi This is why we have a planning process that considers many factors, not just the number of votes. That being said, there are currently 114 issues with more votes than this one. So while cross-platform tooling is strategically important to Microsoft, this particular issue is still pretty far down the priority list, especially for a small team.

@atrauzzi
Copy link

Who do I have to tweet at for you guys to get more resources? 😉

You're like...the 2nd most important .net Core project in the ecosystem IMO!?

@ErikEJ
Copy link
Contributor

ErikEJ commented Feb 23, 2020

@atrauzzi I am planning a .NET Core command line tool that does what the VS extension does (in terms of generating scaffolding code)

@ErikEJ
Copy link
Contributor

ErikEJ commented Feb 23, 2020

You can vote here: ErikEJ/EFCorePowerTools#340

@bricelam
Copy link
Contributor

bricelam commented Mar 3, 2020

Related: #3988

@ajcvickers ajcvickers assigned lajones and unassigned bricelam Mar 12, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0, Backlog Mar 12, 2020
@lajones lajones added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Mar 26, 2020
@darkguy2008
Copy link

This is awesome, thanks a lot for your hard work!!! :D

@lajones
Copy link
Contributor

lajones commented Mar 26, 2020

@darkguy2008 You're very welcome :-)

@ajcvickers ajcvickers modified the milestones: 5.0.0, 5.0.0-preview3 Mar 31, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0-preview3, 5.0.0 Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-scaffolding area-tools closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-2.1 type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants