Closed alexandis closed 1 year ago
Are you saying that some tables do get upper-cased, but others no? If that's the case, then there's likely some place in the code somewhere which explicitly sets the naming for the tables not getting upper-cased (this plugin's convention only affects names which aren't explicitly set).
[...] by default Oracle creates everything in uppercase, no matter what was the input. So I already have all these tables in DB and the script is incorrect. Devart resolved this issue by configured option to disable quotes.
Wouldn't this break if you happened to have two .NET properties with names differing only by their case? In any case, if this is something you want to do, you can replace the Oracle's ISqlGenerationHelper and change the behavior to not emit quotes.
@roji thank you for the reply. Regarding the first part - ok, clear now. Regarding the second one - yes, I understand the risks, but at least would be great to have the option taking the responsibility and changing the generation behavior. So thank you for the advice with ISqlGenerationHelper
, will have a look at it.
Sorry for bothering you again, @roji
ISqlGenerationHelper
helped me to deal with quotations and letter case. But probably you know how to deal with letter case here?
Not sure exactly what you're asking - are you using EFCore.NamingConventions or not?
At least I've tried to:
However as seen from the previous screenshot, the table and column names referenced in the system table SELECT are in camel-case. But I have all the tables and column names in my Oracle DB in upper-case, this has been done automatically when these tables have been created (despite the case which was declared by the earlier generated migration script).
Now I'm trying to force everything in my current script to be upper-cased, including those references. I'm not sure your extension can deal with such as you described in your previous message. But I need to do it somehow.. Preferrably automatically, by overriding the class similar to OracleSqlGenerationHelper
...
However as seen from the previous screenshot, the table and column names referenced in the system table SELECT are in camel-case
If you're doing UseUpperCaseNamingConvention, all identifiers should be upper-cased for you - if not that's a bug, and that's what we should probably concentrate on... Are all identifiers (table/column names) camel-case?
I think this is a normal behavior of the plugin. The fact is that I can't resolve my problem with it. We use 3rd part framework and the creator set his table names in camel case. But our client demanded the DB setting which causes all DB entities to be created in uppercase. So what I need is to make a migration script generate everything in uppercase - no matter what are the explicit settings for naming...
OK. If identifiers are being explicitly set, this plugin indeed cannot do anything to them. At that point your only option is to either set them manually yourself, or perform the upper-casing yourself in SqlGeneratorHelper.DelimitIdentifier/EscapeIdentifier (note that there are several overloads there).
I see. Ok. Thank you for clarification. I uppercased the entities names using the Helper, but it didn't affect the names in SELECT from system tables on screenshot. That's why I thought it needs another way.. Probably I need to take a more careful look at the Helper. Or just "postprocess" the script manually with Regex in Notepad++ :)
Yeah, that query doesn't render SQL identifiers - the table/column names are rendered as text inside the queries, and so it doesn't go through the SQL generation helper (that's also why there are no quotes - they're not identifiers). For that case there's nothing you can do within EF Core, AFAIK.
I'm trying to apply the extension like this:
I run
Add-Migration
, then -Script-Migration
from Package Manager Console, but looks like there is no trace of the extension, the case for tables / columns / indexes is what it was before, in some cases it is uppercase, in some cases it is camel... What is going on? I don't get it? I thought that everything will be in uppercase now:I don't know if such generation is the reason, but these
CREATE
commands are not supposed to be here at all: by default Oracle creates everything in uppercase, no matter what was the input. So I already have all these tables in DB and the script is incorrect. Devart resolved this issue by configured option to disable quotes. Unfortunately, it is not up-to-date with NET7, so I hoped I would be able to complete the migration with this extension...Honestly - it would be much easier just to allow removing the quotes for Oracle: it would resolve the problems in many scenarios ;)