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

"POCO" Convention" and EntitySuffix in Scaffold-DbContext? #6510

Closed
RandyBuchholz opened this issue Sep 10, 2016 · 3 comments
Closed

"POCO" Convention" and EntitySuffix in Scaffold-DbContext? #6510

RandyBuchholz opened this issue Sep 10, 2016 · 3 comments

Comments

@RandyBuchholz
Copy link

Sometimes it seems that the entity objects that EF creates get in my way from a naming perspective. For example, I may have a "Consumer" table in my database, and a "Consumer" domain object in my business objects. If I'm doing DB first, EF creates a Consumer entity object that eats up that name when I scaffold. There are some approaches to minimize the problem here, like just using namespaces, but of course there are drawbacks to that. Prior to Core I used partial classes to help address this type of thing and they worked pretty well. But with Core the built-in DI limits this since you can only have a single constructor on classes that use this container. Another sometimes concern is that I'm exposing my entities if I let users access my context directly, so I push these down a layer, which then adds another "name duplication concern". I am wondering if it makes sense to add something like a "POCO Convention" to EF. I'm not sure exactly how it would work, but I wanted to start a discussion.

In the most simple form the objects defined in a context could follow the naming convention ...Entity - ConsumerEntity. In this way we would know that the type definition for this class has some relationship to EF. Just like other convention-based approaches tooling/components can be aware if they want to and ignore if they don't. For the DB first people (like me) we could have a switch on Scaffold-DbContext called -EntitySuffix if present it would add the suffix "Entity" to the entity classes.

I think just adding a -suffix switch to scaffold would be valuable in some scenarios and may be an easy way to help get this started. If I could do Scaffold-DbContext ... -suffix Entity and have it add the suffix in the right places that would help with my naming extra work.

@ajcvickers
Copy link
Member

Note for triage: templates?

@bricelam
Copy link
Contributor

We have items on our backlog to improve the extension points of Reverse Engineer (including via templates). Until then, you can use the method described in https://gist.github.com/natemcmaster/353f4ab3efb4514eeaec846df28f0e24

@bricelam
Copy link
Contributor

Closing as a dupe of #4038

@bricelam bricelam removed this from the 1.1.0 milestone Sep 12, 2016
@bricelam bricelam removed their assignment Sep 12, 2016
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
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

4 participants