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

Rewrite schema name #56

Open
kYann opened this issue Jan 5, 2021 · 6 comments
Open

Rewrite schema name #56

kYann opened this issue Jan 5, 2021 · 6 comments
Labels
blocked enhancement New feature or request
Milestone

Comments

@kYann
Copy link

kYann commented Jan 5, 2021

Hello,

I have a convention that set the schema name from the table namespace.
I could write a snake case namespace but I like having separate conventions (one for the naming, one for the "casing").

So it would be great if schema name were rewrite by the NamingConventions.

P.S. : I saw an issue on the subject but it was closed and you were looking for case where the schema name would not be explicitly set by the user (#28).

@roji
Copy link
Member

roji commented Jan 9, 2021

I have a convention that set the schema name from the table namespace.

You mean the namespace of the CLR entity type, right? What would be the desired behavior if more than one CLR type is mapped to the same table (e.g. table splitting), with different namespaces?

Regardless, this plugin doesn't aim to support every name rewriting possibility that users may want (that would be an infinite list...). I can see value in allowing users to provide a hook for the actual rewriting function (tracked by #42), but rewriting the schema based on the CLR type is a much more advanced thing which wouldn't fit in that.

@kYann
Copy link
Author

kYann commented Jan 10, 2021

Yes the Clr Entity Type. This is my convention, and I don't have that case so I don't handle it.

As I said, I have my conventions that I register before the naming convention that set name as I want. But then I use your conventions for name rewriting.
I think it's cleaner to have a convention for setting name and a convention for "name format".

But the EFCore.NamingConventions does not touch schema name. So I'm proposing to just add the necessary code to also rewrite schema name (I'm willing to do the PR and also provide an options to activate schema rename or not).

Thanks,

@roji
Copy link
Member

roji commented Jan 10, 2021

@kYann are you saying you've written another EF Core plugin with this convention? Or some other mechanism?

If you've written a plugin with a real convention, then having multiple conventions rewriting names is probably not going to work very well at this point in EF Core - there are some ordering/interference issues, and cases where this plugin would probably reset what you convention has already done.

I'd recommend simply looping over all entities at the end of your OnModelCreating, and setting your schema there, that should work well without any sort of interference.

@kYann
Copy link
Author

kYann commented Jan 11, 2021 via email

@roji roji added the enhancement New feature or request label Jan 11, 2021
@roji
Copy link
Member

roji commented Jan 11, 2021

Well, I guess this plugin could rewrite the schema name if one is set by some previous convention (of course, leaving any explicit setting alone)... This way, if your convention runs before mine, everything should work OK...

@roji roji added this to the Backlog milestone Jan 3, 2024
@roji
Copy link
Member

roji commented Jan 3, 2024

Having multiple conventions rewriting names currently won't work well because of lack of support on the EF infrastructure side.

@roji roji added the blocked label Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants