ErikEJ/EFCorePowerTools

Add "Entity" suffix to models generated from tables using efpt.renaming.json while keeping default logic for stored procedures

contione opened this issue · 8 comments

When using EF Core Power Tools to generate models from a database, I want to add an "Entity" suffix to all models generated from tables while keeping the default naming logic for models generated from stored procedures. However, I am unsure how to configure efpt.renaming.json to achieve this.

Provide technical details

  • EF Core Power Tools version: 2.6.403

  • Exact Visual Studio version: Visual Studio 2022 17.8.0

  • Database engine: SQL Server

  • EF Core version in use: EF Core

  • Is Handlebars templates used: no

  • Is T4 templates used: no

  • Is a SQL Server .dacpac used: no

Currently, I am using the following configuration in efpt.renaming.json, but the result is that only the models generated from stored procedures have the "Entity" suffix added, while the models generated from database tables still retain their original names. However, what I want is to have the "Entity" suffix added to the models generated from tables, and the models generated from stored procedures should remain unchanged.
[
{
"SchemaName": "dbo",
"TablePatternReplaceWith": "$0Entity",
"TableRegexPattern": "^.+$",
"UseSchemaName": true
}
]

Please share a full repro, including schema create scripts and your efpt.config.json file

{
   "CodeGenerationMode": 4,
   "ContextClassName": "",
   "ContextNamespace": "DataContext",
   "FilterSchemas": false,
   "IncludeConnectionString": false,
   "ModelNamespace": "Core",
   "OutputContextPath": "",
   "OutputPath": "Entities",
   "PreserveCasingWithRegex": true,
   "ProjectRootNamespace": "",
   "Schemas": null,
   "SelectedHandlebarsLanguage": 2,
   "SelectedToBeGenerated": 0,
   "T4TemplatePath": "",
   "Tables": [
           {
         "Name": "[dbo].[UserInfo]",
         "ObjectType": 0
      },
      {
         "Name": "[dbo].[GetUserInfo]",
         "ObjectType": 1
      }
   ],
   "UiHint": null,
   "UncountableWords": null,
   "UseAsyncStoredProcedureCalls": true,
   "UseBoolPropertiesWithoutDefaultSql": false,
   "UseDatabaseNames": true,
   "UseDateOnlyTimeOnly": true,
   "UseDbContextSplitting": false,
   "UseDecimalDataAnnotationForSprocResult": true,
   "UseFluentApiOnly": false,
   "UseHandleBars": false,
   "UseHierarchyId": false,
   "UseInflector": true,
   "UseLegacyPluralizer": false,
   "UseManyToManyEntity": false,
   "UseNoDefaultConstructor": false,
   "UseNoNavigations": false,
   "UseNoObjectFilter": false,
   "UseNodaTime": false,
   "UseNullableReferences": true,
   "UsePrefixNavigationNaming": false,
   "UseSchemaFolders": false,
   "UseSchemaNamespaces": false,
   "UseSpatial": false,
   "UseT4": false
}

@ErikEJ Thank you so much for taking

Create scripts for the table and sproc please

Create scripts for the table and sproc please
I don't quite understand if I need to specify aliases one by one in the table configuration? If so, it feels quite troublesome.

I mean scripts to create the table and the stored procedure listed in your config file