-
Notifications
You must be signed in to change notification settings - Fork 75
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
User-defined rewriting conventions #42
Comments
It's more a personal naming convention than widely used. In such cases it's better to implement it yourself rather to include into a common library. |
What we could do, is to provide a hook to allow users to provide their own rewriters. |
Seconded. I originally browsed this library with the hope to find a concise single extension method or class to customize naming conventions. After looking at the code it seems that building an IDbContextOptionsExtension requires a non-trivial amount of internal knowledge of EFCore. And by building this customization you own the long-term responsibility of compatibility in a framework known to change. Wouldnt supporting this be as simple as adding an option for a custom |
Probably... It indeed shouldn't be very hard. |
I ended up replacing the library with this
|
@PeteW that's a possible approach, though it's hacky and wouldn't work like a full solution. Customizing DelimitIdentifier only controls how EF Core sends table/column names to the database - but is not taken into account for EF Core's model. For example, this means that no migrations will be generated for renaming everything when you activate the above. Logging of table/column names (where DelimitIdentifier isn't called) would also not be affected. However, if you're OK with these limitations, that approach should work too. |
Just to make sure: Defining custom naming conventions is still not possible, right? |
Right. |
Thanks for the confirmation. Two more questions: We postfix our entities with "Entity" and obviously want to get rid of that for the table names. Is this something, that would be a good match for a custom naming convention or should that be solved differently? Also how does the If our usecase would be reasonable for naming conventions, I'd happily provide a PR to add support for custom naming rules. |
Hi,
I used to work with convention like this. Let's say we have entitites:
It should produce this data structure
Table: dbo.SUBJECT, columns:
S_ID,
S_NAME,
S_SURNAME,
S_REL_PUBLIC_PROFILE,
S_REL_DECLARATION_ITEM
Table: dbo.PUBLIC_PROFILE.
PP_ID
PP_NAME
Table: dbo.DECLARATION_ITEM.
DI_ID,
DI_NAME
Rules:
-Everything should be uppercase,
-Words are joined with _ ,
-All columns starts with prefix that consists of first letters of words that are parts of entity name.
This convention makes querying database very easy. For example usually when you have different prefixes in tables you can write joins without introducing aliases.
Is there a chance to add this convention?
The text was updated successfully, but these errors were encountered: