Skip to content

Property Navigation Gets Incorrect Suffix (Dao) in 1:1 Relationship After Reverse Engineering #2909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
donwaka opened this issue Mar 21, 2025 · 2 comments
Closed
2 of 3 tasks
Labels
question Further information is requested

Comments

@donwaka
Copy link

donwaka commented Mar 21, 2025

Bug description / exact reproduction steps

Problem

When using EF Core Power Tools to reverse engineer the AreaSessions and AreaSessionAvailabilities tables, which are related in a 1:1 relationship via AreaSessionAvailabilities.AreaSessionId, the properties are being generated with the suffix Dao, which is incorrect. Specifically, the property in the generated AreaSessionDao class for the navigation to AreaSessionAvailabilityDao is generated as:
public virtual AreaSessionAvailabilityDao? AreaSessionAvailabilityDao { get; set; }

This should be generated as:
public virtual AreaSessionAvailabilityDao? AreaSessionAvailability { get; set; }

Steps to Reproduce
Configure reverse engineering in EF Core Power Tools for the AreaSessions and AreaSessionAvailabilities tables.
Set the following renaming for the tables:
AreaSessions -> AreaSessionDao
AreaSessionAvailabilities -> AreaSessionAvailabilityDao
Run the reverse engineering process.
The generated AreaSessionDao class includes a navigation property AreaSessionAvailabilityDao with the wrong suffix.

Expected Behavior
The property should be named AreaSessionAvailability (without the Dao suffix) in the generated AreaSessionDao class.

Additional Information
It would be helpful to allow customization or a configuration option to remove the automatic suffix added to navigation properties, especially in the case of 1:1 relationships.

There you have an example. To reproduce it, I use a SQL Server database to apply the reverse engineering

ISA.Assignments.Service.zip

Your code

-- There the tables used
CREATE TABLE [Assignments].[AreaSessions]
(
	[Id] INT NOT NULL, 
        [EventId] INT NOT NULL
)

CREATE TABLE [Assignments].[AreaSessionAvailabilities] (
    [AreaSessionId] INT                                                NOT NULL,
    [Capacity]      INT                                                NOT NULL DEFAULT 0,
    [Availability]  INT                                                NOT NULL DEFAULT 0,
    CONSTRAINT [PK_Assignment_AreaSessionAvailabilities] PRIMARY KEY CLUSTERED ([AreaSessionId] ASC),
    CONSTRAINT [FK_Assignment_AreaSessionAvailabilities_AreaSessions_AreaSessionId] FOREIGN KEY ([AreaSessionId]) REFERENCES [Assignments].[AreaSessions] ([Id]),
    PERIOD FOR SYSTEM_TIME ([BeginDate], [EndDate])
)

ALTER TABLE [Assignments].[AreaSessionAvailabilities] 
    ADD CONSTRAINT UQ_AreaSessionId UNIQUE (AreaSessionId);

Stack traces


EF Core Power Tools version

2.6.911

EF Core Power Tools CLI version

No response

Database provider

SQL Server

Target framework

.NET 8

IDE

No response

Additional features in use

  • T4 templates
  • SQL Server .dacpac
  • Handlebars template
@ErikEJ
Copy link
Owner

ErikEJ commented Mar 21, 2025

Have you tried

"UsePrefixNavigationNaming": true,

@ErikEJ ErikEJ added the question Further information is requested label Mar 21, 2025
@ErikEJ
Copy link
Owner

ErikEJ commented Mar 22, 2025

Hmm.. basically you are asking for reverse engineering to read your mind. T4 is the only solution for this see issue #1499

@ErikEJ ErikEJ closed this as not planned Won't fix, can't repro, duplicate, stale Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants