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

Reveng: custom naming of properties, dbset and entity? #11056

Closed
ErikEJ opened this issue Feb 24, 2018 · 9 comments
Closed

Reveng: custom naming of properties, dbset and entity? #11056

ErikEJ opened this issue Feb 24, 2018 · 9 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@ErikEJ
Copy link
Contributor

ErikEJ commented Feb 24, 2018

Is this possible by overriding the 3 methods in RelationalScaffoldingModelFactory? (Internal, I know)

@smitpatel
Copy link
Contributor

How about injecting ICandidateNamingService?
Currently naming pipeline works this way

  1. From DatabaseModel object fetch name.
  2. Use CandidateNamingService to generate candidateName from name (this is where pascal casing happens.
  3. Run candidateName through CSharpUtilities to generate a valid C# identifier.
  4. Take the identifier generated and run through pluralizer.
  5. Take the identifier after singularize/pluralize and uniquify it with existing identifier if any (e.g. class cannot contain property same name as class i think)

If you are looking to update just a part of above pipeline then perhaps you could achieve using service.

Though above pipeline is integrated in code in very awkward way and we have cleanup task for that. You can override from RelationalScaffoldingModelFactory and take control of full pipeline (though it could break in future). Allowing to override is what made those methods virtual in first place. And not having a good pipeline implemented right now makes the class internal.

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Feb 25, 2018

Thanks!

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Mar 4, 2018

@smitpatel Actually, ICandidateNamingService is not specific enough (it accepts a string, not a DatabaseTable or DatabaseColumn object)

@smitpatel smitpatel reopened this Mar 4, 2018
@ErikEJ
Copy link
Contributor Author

ErikEJ commented Mar 4, 2018

Thanks, maybe we can briefly discuss later this week?

@ajcvickers
Copy link
Contributor

@ErikEJ We can certainly discuss this week, but regardless we would be interested in getting a PR for the changes you would like--it's certainly something we would consider.

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Mar 6, 2018

I guess it should be a change from:

  string GenerateCandidateIdentifier([NotNull] string originalIdentifier);

To:

  string GenerateCandidateIdentifier([NotNull] DatabaseTable databaseTable);

and

  string GenerateCandidateIdentifier([NotNull] DatabaseColumn databaseColumn);

Makes sense?

@ajcvickers
Copy link
Contributor

@ErikEJ Looks good. PR?

@ajcvickers ajcvickers added this to the 2.1.0 milestone Mar 7, 2018
@ErikEJ
Copy link
Contributor Author

ErikEJ commented Mar 8, 2018

Coming up!

ErikEJ added a commit to ErikEJ/EntityFramework that referenced this issue Mar 9, 2018
@ErikEJ
Copy link
Contributor Author

ErikEJ commented Mar 10, 2018

PR submitted

bricelam pushed a commit that referenced this issue Mar 19, 2018
@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 Mar 19, 2018
@ajcvickers ajcvickers modified the milestones: 2.1.0-preview2, 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. type-enhancement
Projects
None yet
Development

No branches or pull requests

4 participants