question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

efpt.renaming.json skipping and removing a table on scaffolding

See original GitHub issue

Provide steps to reproduce a bug

This is mostly a question/maybe bug report.

I have an efpt.renaming.json definition with an entry that looks like so.

[
   {
      "SchemaName": "Retail",
      "Tables": [
         {
            "Columns": [ ],
            "Name": "POSSystemType",
            "NewName": "POSSystemType"
         }
      ],
      "UseSchemaName": false
   }
]

This scaffolds fine when it is alone. However, when I add the other tables from that schema (as I’m trying to preserve frequent POS and SKU usage), then this entry specifically gets skipped and removed after the scaffold run with the UI tool. The other tables are scaffolded as expected. There is also a table entry after this one which also gets scaffolded as expected.

I tried pairing down the renaming file to just two entries like so.

[
  {
    "SchemaName": "Retail",
    "Tables": [
      {
        "Columns": [
          {
            "Name": "POSSystemId",
            "NewName": "POSSystemId"
          },
          {
            "Name": "SKU",
            "NewName": "SKU"
          }
        ],
        "Name": "ItemSKU",
        "NewName": "ItemSKU"
      },
      {
        "Columns": [
        ],
        "Name": "POSSystemType",
        "NewName": "POSSystemType"
      }
    ],
    "UseSchemaName": false
  }
]

Upon running again the POSSystemType table entry is removed. The ItemSKU table entry remains. It seems like the moment another entry is in the list POSSystemType gets ignored/removed. Going again back to just that entry as the only one and running the tool again produces expected output and POSSystemType is still there.

I saw mention of doing renamings with the UI tool, but I haven’t seen a way to do that. I was thinking maybe if I define these in the UI as I’ve seen hinted at then I could do a diff and see if there’s a mismatch. Would you be so kind as to point out where/how that’s done?

I generated my renamings file programmatically with some custom code and did the JSON generation with a standard JsonSerializer.Serialize so it’s valid json. Over the course of my experiments I also re-validated the json as well.

Provide technical details

  • EF Core Power Tools version: 2.5.1544

  • Exact Visual Studio version: 2022 17.7.0

  • Database engine: SQL Server

  • EF Core version in use: 7

  • Is Handlebars templates used: seen with either

  • Is T4 templates used: seen with either

  • Is a SQL Server .dacpac used: no

Here is my redacted config.

{
   "CodeGenerationMode": 3,
   "ContextClassName": "[context name]",
   "ContextNamespace": null,
   "DefaultDacpacSchema": null,
   "FilterSchemas": false,
   "IncludeConnectionString": false,
   "ModelNamespace": null,
   "OutputContextPath": null,
   "OutputPath": "Scaffold",
   "PreserveCasingWithRegex": true,
   "ProjectRootNamespace": "[project root]",
   "Schemas": null,
   "SelectedHandlebarsLanguage": 0,
   "SelectedToBeGenerated": 0,
   "T4TemplatePath": null,
   "Tables": [...big list of tables...],
   "UiHint": "[connection name]",
   "UncountableWords": null,
   "UseBoolPropertiesWithoutDefaultSql": false,
   "UseDatabaseNames": false,
   "UseDateOnlyTimeOnly": true,
   "UseDbContextSplitting": true,
   "UseFluentApiOnly": false,
   "UseHandleBars": false,
   "UseHierarchyId": false,
   "UseInflector": false,
   "UseLegacyPluralizer": false,
   "UseManyToManyEntity": true,
   "UseNoDefaultConstructor": true,
   "UseNoObjectFilter": false,
   "UseNodaTime": false,
   "UseNullableReferences": true,
   "UseSchemaFolders": true,
   "UseSchemaNamespaces": true,
   "UseSpatial": false,
   "UseT4": false
}

Issue Analytics

  • State:closed
  • Created a month ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Aug 15, 2023

I implemented a fix for this in the latest daily build, would be grateful if you could try it out.

0reactions
ErikEJcommented, Aug 14, 2023

Thanks for finally sharing enough information for a proper repro! I will have a look tomorrow

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reverse Engineering · ErikEJ/EFCorePowerTools Wiki
To customize names of DbSets and entities/properties, you can place a file named efpt.renaming.json at the root of your project. (This file will ......
Read more >
Remove tableprefix with .net Core
You can rename tables and columns during the reverse engineering process by adding a file called efpt.renaming.json in the project folder.
Read more >
EF Core Power Tools database reverse engineering
To implement renaming of entities and properties, add a .json file named efpt.renaming.json at the root of your project.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found