You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not a bug, this is a question - how do I include the schema name when generating entities?
For example, Prd.Store is currently generated as Store.cs, but I want it to be named Prd_Store.cs
How do I accomplish this? And I don't really want to specify each table manually, since I have over 400 tables that should follow this pattern: {schema}_{tableName}.cs
The only issue I am still encountering - after having disabled that flag, the tables are no longer named as they are in the database - the casings are now CamelCase, and underscores are removed. Which I don't really like, I prefer having 100% the same table name, only with prepended schema name to it.
Even if I explicility add the underscore in the "TablePatternReplaceWith", it is still removed afterwards.
But if that is difficult to fix, then I can live with it.
If you mean the regex part, then I added the underscore here: "TablePatternReplaceWith": "Order_$0"
Result: "OrderItem.cs", should have been: "Order_Item.cs"
Activity
ErikEJ commentedon Nov 3, 2020
I think you can use the renaming feature: https://github.com/ErikEJ/EFCorePowerTools/wiki/Reverse-Engineering#custom-renaming-with-efptrenamingjson (combine "UseSchemaName" with a regex)
ErikEJ commentedon Nov 3, 2020
Also, having 400 tables in a single DbContext will cause you pain.
ClassyCircuit commentedon Nov 3, 2020
They are split across multiple contexts, so it's more like 40-50 tables per one dbcontext.
What does the "UseSchemaName" flag do? I don't see any examples where it's being used.
ClassyCircuit commentedon Nov 3, 2020
I don't understand how to use the regex feature, I followed the example in linked issue, and this is what I came up with:
But it doesn't rename anything.
ErikEJ commentedon Nov 3, 2020
It includes the schema name in the property name - try it out!
ErikEJ commentedon Nov 3, 2020
Start with the example in the linked PR
ClassyCircuit commentedon Nov 3, 2020
I used the sample that user e-ngin wrote 4 days ago:
I just replaced "dbo" with "Fact", and also added the missing square brackets, so in the end it looks like this:
Then I regenerated entities, but they weren't renamed. Am I missing anything in the file?
ErikEJ commentedon Nov 3, 2020
There could be a bug, please use the exact same parameters as in the PR first.
ErikEJ commentedon Nov 3, 2020
If you still encounter issues, please share your renaming json file, and a sample create table script.
ClassyCircuit commentedon Nov 3, 2020
I got it working :)

The issue was this flag, I had to disable it:
And if anyone else in the future needs this functionality, here is the config file I used:
The only issue I am still encountering - after having disabled that flag, the tables are no longer named as they are in the database - the casings are now CamelCase, and underscores are removed. Which I don't really like, I prefer having 100% the same table name, only with prepended schema name to it.
Even if I explicility add the underscore in the "TablePatternReplaceWith", it is still removed afterwards.
But if that is difficult to fix, then I can live with it.
@ErikEJ thanks for the assistance!
ErikEJ commentedon Nov 3, 2020
Great. I think the database names issue may be fixed in EF Core 5
ErikEJ commentedon Nov 3, 2020
Where is the _ by the way?
ClassyCircuit commentedon Nov 3, 2020
If you mean the regex part, then I added the underscore here:
"TablePatternReplaceWith": "Order_$0"Result: "OrderItem.cs", should have been: "Order_Item.cs"
ErikEJ commentedon Nov 3, 2020
I have linked your sample from the docs...
tafs7 commentedon Mar 12, 2021
@ErikEJ - Can renaming with regex patterns be used for all navigations?
For example, every time we see a navigation property that would be generated as this:
public virtual Payor PayorCompany { get; set; }instead we rename to simply this:
public virtual Payor Payor { get; set; }I can do this one by one in the
efpt.renaming.jsonfile for each table in the"Tables[]"array, like this:[ { "SchemaName": "dbo", "Tables": [ { "Name": "Table1", "Navigations": [ { "Name": "PayorCompany", "NewName": "Payor" } ], "NewName": null }, { "Name": "Table2", "Navigations": [ { "Name": "PayorCompany", "NewName": "Payor" } ], "NewName": null }, //..... repeat for each table where this might apply..... ] } ]but would be nice to just tell the tool to apply that renaming rule for EVERY table.
ErikEJ commentedon Mar 12, 2021
Suggest you post a new issue with that idea!
tafs7 commentedon Mar 12, 2021
suggested - #848
Thanks!