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.

Renamed column not effective for Context configuration

See original GitHub issue

NewName for Column in efpt.property-renaming.json not effective for Context generation (Model and context are in different project)

Provide steps to reproduce

Tables:

CREATE TABLE session_slots (
 id int4 NOT NULL,
 user_id int4 NOT NULL,
 guid varchar NOT NULL,
 application_name varchar NOT NULL,
 CONSTRAINT pk_session_slots_id PRIMARY KEY (id),
 CONSTRAINT un_session_slots__guid UNIQUE (guid));

CREATE TABLE session_slot_data (
 id int4 NOT NULL,
 session_slot_guid varchar NOT NULL,
 "key" varchar NOT NULL,
 "data" bytea NOT NULL,
 CONSTRAINT pk_session_slot_data_id PRIMARY KEY (id),
 CONSTRAINT un_session_slot_data__session_slot_guid_key UNIQUE (session_slot_guid, key),
 CONSTRAINT fk_session_slot_data_session_slot_guid__ FOREIGN KEY (session_slot_guid) REFERENCES session_slots(guid) ON DELETE CASCADE);

efpt.property-renaming.json:

{
  "Classes": [
    {
      "Name": "SessionSlot",
      "Properties": [
        {
          "Name": "SessionSlotDatas",
          "NewName": "SessionSlotData"
        }
      ]
    },
    {
      "Name": "SessionSlotData",
      "Properties": [
        {
          "Name": "SessionSlotGu",
          "NewName": "SessionSlot"
        }
      ]
    }
  ]
}

Result in DbContext OnModelCreating:

 modelBuilder.Entity<SessionSlotData>(entity =>
            {
                entity.ToTable("session_slot_data", "xxx");

...

                entity.Property(e => e.SessionSlotGuid)
                    .IsRequired()
                    .HasColumnType("character varying")
                    .HasColumnName("session_slot_guid");

                entity.HasOne(d => d.SessionSlotGu)
                    .WithMany(p => p.SessionSlotDatas)
                    .HasPrincipalKey(p => p.Guid)
                    .HasForeignKey(d => d.SessionSlotGuid)
                    .HasConstraintName("fk_session_slot_data_session_slot_guid__");
            });

Provide technical details

  • EF Core version in use: (e.g. EF Core 6)

  • Is Handlebars used: no

  • Is T4 used: no

  • Is .dacpac used: no

  • EF Core Power Tools version: (2.5.1293)

  • Database engine: (Postgres)

  • Visual Studio version: (Visual Studio 2022)

Issue Analytics

  • State:closed
  • Created 6 months ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Apr 21, 2023

@Endre1980 Thanks for the info, looks like a duplicate of #1769 - which is not something I currently plan to fix. Glad my tool features enabled you to work around this.

0reactions
Endre1980commented, Apr 21, 2023

Hi Erik,

We created a Test solution, so you can try the issue: https://github.com/Endre1980/SessionSlotTest

Test.Core project: The SessionSlotData has a SessionSlotGuid string property and a navigation property for SessionSlotData, which by default is generated with the name of SessionSlotGu.

The renaming in the efpt.property-renaming.json is affected by the generation and the navigation property will be renamed.

Test.DAL.EntityFramework: In the TestContext the navigation property renaming is not affected and named as SessionSlogGu.

The efpt.property-renaming.json is not affected by the generation.

To bypass the issue we used the following method: In the Test.Core project, in the efpt.property-renaming.json: The SessionSlotGu NewName is SessionSlotGuidNavigation.

In the Test.DAL.EntityFramework project:

  • In the efpt.renaming.json the session_slot_guid (tablename) NewName is SessionSlotGuidLinkNavigation.
  • efpt.postrun.cmd is created to rename SessionSlotGuidLinkNavigation and SessionSlotGuidLinkNavigationNavigation to a proper name.
Read more comments on GitHub >

github_iconTop Results From Across the Web

SharePoint Lists: Renamed Lists and Columns are not ...
I was wondering already on the initial list, that there was not "edit" in context menu anymore, but I could do this via...
Read more >
Spring Boot + JPA : Column name annotation ignored
SQL generated by this created test_name as the columns name. After looking for a solution I have found that spring.jpa.hibernate.naming_strategy ...
Read more >
Column with name attribute not working property on entities
Hi, I'm using spring-boot-starter-parent and spring-boot-starter-data-jpa (version 1.1.9). I found some strange behaviour on entities.
Read more >
Repetitive Column Names are not renamed 1,2,3,4......
Hi All, I am using Alteryx to reformat data into a nicer structure. The initial input has the same data column titles repeating....
Read more >
Refresh Errors from Changing Column Names ... - YouTube
It creates a working environment suited for normal users, meaning tasks such as data extraction ... Automatically rename columns in Power BI.
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