Comments (8)
@UseMuse Alternative would be to use a T4 template and fix the names there. Seems like a reasonable workaround you have found.
from efcorepowertools.
Please provide a schema, options file and expected versus actual results.
from efcorepowertools.
//efpt.config.json
{
"CodeGenerationMode": 2,
"ContextClassName": "ReadOnlyMsSqlDbContext",
"ContextNamespace": "MyApiCore",
"FilterSchemas": false,
"IncludeConnectionString": false,
"ModelNamespace": "MyApiCore",
"OutputContextPath": "DAL\\MsSql\\DbContext",
"OutputPath": "DAL\\Entity",
"PreserveCasingWithRegex": true,
"ProjectRootNamespace": "",
"Schemas": null,
"SelectedHandlebarsLanguage": 0,
"SelectedToBeGenerated": 0,
"T4TemplatePath": null,
"Tables": [
{
"Name": "[dbo].[t_tag]",
"ObjectType": 0
},
{
"Name": "[dbo].[t_Product]",
"ObjectType": 0
}
],
"UiHint": null,
"UncountableWords": null,
"UseAsyncStoredProcedureCalls": true,
"UseBoolPropertiesWithoutDefaultSql": true,
"UseDatabaseNames": true,
"UseDateOnlyTimeOnly": false,
"UseDbContextSplitting": false,
"UseDecimalDataAnnotationForSprocResult": true,
"UseFluentApiOnly": true,
"UseHandleBars": true,
"UseHierarchyId": false,
"UseInflector": false,
"UseLegacyPluralizer": false,
"UseManyToManyEntity": false,
"UseNoDefaultConstructor": true,
"UseNoNavigations": true,
"UseNoObjectFilter": false,
"UseNodaTime": false,
"UseNullableReferences": true,
"UsePrefixNavigationNaming": false,
"UseSchemaFolders": false,
"UseSchemaNamespaces": false,
"UseSpatial": false,
"UseT4": false
}
//efpt.renaming.json
[
{
"SchemaName": "dbo",
"Tables": [
{
"Columns": [
{
"Name": "id",
"NewName": "Id"
},
{
"Name": "title",
"NewName": "Title"
}
],
"Name": "t_tag",
"NewName": "TTag"
}
],
"UseSchemaName": false
}
]
CREATE TABLE [dbo].[t_tag](
[id] [int] NOT NULL,
[title] [varchar](255) NULL)
CREATE TABLE [dbo].[t_Product](
[ID_Product] [int] NOT NULL,
[Title] [varchar](255) NULL)
Expected result, c# classes
//
public partial class TTag
{
public int Id { get; set; }
public string? Title { get; set; }
}
public partial class t_Product
{
public int ID_Product { get; set; }
public string? Title { get; set; }
}
Historically, all models in the api project had the same class name as in db ms sql (example t_Product), there was a need to use snake case for all new tables (example t_tag).
How to make the majority use naming rules like "Use table and column name directly from the database"
And the smaller part (new entities in the db) used camel case for c#
The ideal option for me is to continue using "Use table and column name directly from the database" with selective renaming of tables that should be named differently than in the database
I plan to make 2 configuration files efpt.config.json
with the global setting "Run cleanup ..." equal to false
in one configuration file with "Use table and column name directly from the database", in the other file without this option
by running these two files, I will get the expected result, it seems that this should work....
from efcorepowertools.
Are there other ways to achieve the result I need in the current reality?
from efcorepowertools.
@UseMuse Alternative would be to use a T4 template and fix the names there. Seems like a reasonable workaround you have found.
Unfortunately, ef core 6 not supports T4 template, transition to 7 and higher is not planned yet, thanks for the feedback
from efcorepowertools.
Assume you are aware that EF Core 6 goes out of support in November, and EF Core 7 is already out of support?
If you like my free tools, I would be very grateful for a rating or review on Visual Studio Marketplace or even a one-time or monthly sponsorship
from efcorepowertools.
I plan to make 2 configuration files efpt.config.json with the global setting "Run cleanup ..." equal to false in one configuration file with "Use table and column name directly from the database", in the other file without this option by running these two files, I will get the expected result, it seems that this should work....
when using two configuration files with the same context name and executing these configuration files, the context is overwritten, I expected summation, it looks like I'll have to give them different names and somehow combine them into one context, since they should all be accessible through one class and interface when injecting a dependency
from efcorepowertools.
Don't assume summation, this is generated code. You can create partial classes to modify the configuration
from efcorepowertools.
Related Issues (20)
- Migrations context-menu is missing HOT 2
- UseDateOnlyTimeOnly = false seems to not be respected in case of TimeSpan HOT 6
- [Feature] Reverse Engineering with configurable OutputDirectories HOT 3
- DAB: Add SQL stored procs (and other fixes)
- Custom T4 templates not being used when reverse engineering HOT 5
- Sign package with sign CLI HOT 2
- Option "Prefer async calls" is missing HOT 3
- Dab follow up
- Errors every time when connecting to localDB in a code first VS2020 blazor web app project. HOT 7
- Data API Builder improvements
- [Feature Request] Support for IncludeColumns (rather than ExcludeColumns) HOT 4
- Possible to use T4 to change the access modifier on the DbContext partial for the Stored Procedure generated code? HOT 4
- it can't detect columns of my complex stored procedure HOT 2
- Add "Entity" suffix to models generated from tables using efpt.renaming.json while keeping default logic for stored procedures HOT 8
- Improvements in generating calls for stored procedures HOT 6
- Problem with executing stored procedure HOT 6
- Doc DAB internal CLI HOT 1
- Add SQL formatter to Powrr Pack
- Unclear prompts when uninstalling EF Core Power Pack HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efcorepowertools.