Navigator naming

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
mnmaric
Posts: 2
Joined: Mon 26 Mar 2018 11:38

Navigator naming

Post by mnmaric » Mon 26 Mar 2018 12:10

We wont to migrate and existing project and to start using Devart Entity Developer (Database first approach) instead of EDM Designer.
Only problem we have is Navigators naming with Entity Developer.

We wont to have naming based on Start entity name (ReferenceClassName) but We Entity Developer always generates ReferenceClassName_PropertyName.

I have seen earlier Ticket How to customize navigation property naming? and tried to unset "Add constraint details to navigation properties" in "Model Settings > Synchronization > Model Naming " but I always get the same result.

I am using Entity Developer version 6.2.439 (Trial), Database first approach.

Example:
Table1: cfg_form
Table2: cfg_form_control with FK to cfg_form_id

in cfg_form.cs
I need: this.cfg_form1 = new HashSet<cfg_form>();
but I get: his.cfg_form_cfg_form_id_parent1 = new HashSet<cfg_form>();

Thanks!

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Navigator naming

Post by Shalex » Thu 29 Mar 2018 17:11

After you clear selection of the "Add constraint details to navigation properties" option, it will affect only newly added tables to the model. Naming of the existing classes will remain the same, you should readd them to the model.

If this information doesn't help, please specify:
1) you are working with Devart Entity Model (*.edml), aren't you?
2) your target server is SQL Server, isn't it?
3) send us a test model for reproducing the issue and the corresponding DDL script

mnmaric
Posts: 2
Joined: Mon 26 Mar 2018 11:38

Re: Navigator naming

Post by mnmaric » Mon 02 Apr 2018 08:51

Dear,

Thank you for fast reply.

Answers to your questions are:

After every change in Model settings I have deleted and re-added entities (recreated entire model).

1) you are working with Devart Entity Model (*.edml), aren't you?
YES

2) your target server is SQL Server, isn't it?
YES

3) send us a test model for reproducing the issue and the corresponding DDL script

Ising link(https://www.dropbox.com/s/883ac07lwi8bf ... B.sql?dl=0) you have test DB with two tables, cfg_form and cfg_form_control.

Initially for demonstration purposes I have set one Foreign Key:

Foreign Key Base table: cfg_form_control
Foreign Key Columns: cfg_form_id_with_details
Primary Key Base Table: cfg_form
Primary Key Columns: cfg_form_id

When I generate model from database using Devart Entity Model ("Add constraint details to navigation properties" selection is cleared) this Navigation property is named cfg_form, as I expected it to be.



But, after I add another relation from cfg_form_control to cfg_form using script:

ALTER TABLE dbo.cfg_form_control ADD CONSTRAINT
FK_cfg_form_control_cfg_form FOREIGN KEY
(
cfg_form_id
) REFERENCES dbo.cfg_form
(
cfg_form_id
) ON UPDATE NO ACTION
ON DELETE NO ACTION

GO
ALTER TABLE dbo.cfg_form_control SET (LOCK_ESCALATION = TABLE)
GO

and recreate the model using Devart Entity Model, Navigation properties are named cfg_form_cfg_form_id_with_details (please notice that before I added another FK this property was called cfg_form) and cfg_form_cfg_form_id. I expected it to be: cfg_form and cfg_form1.



To repeat this situation:

1. Create DB using script,
2. Create Devart Entity Model (Database first, "Add constraint details to navigation properties" cleared)
3. Navigation property in cfg_form_control is named cfg_form
4. Add another FK in cfg_form_control using:
ALTER TABLE dbo.cfg_form_control ADD CONSTRAINT
FK_cfg_form_control_cfg_form FOREIGN KEY
(
cfg_form_id
) REFERENCES dbo.cfg_form
(
cfg_form_id
) ON UPDATE NO ACTION
ON DELETE NO ACTION

GO
ALTER TABLE dbo.cfg_form_control SET (LOCK_ESCALATION = TABLE)
GO

5. Update model from Database
6. Navigation properties in cfg_form_control are now named: cfg_form_cfg_form_id_with_details (changed from previous name that was cfg_form) and cfg_form_cfg_form_id.

7. If I understand Devart documentation correctly when "Add constraint details to navigation properties" cleared, in this situation Navigation names should be cfg_form and cfg_form1 ?



Thanks!

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Navigator naming

Post by Shalex » Mon 02 Apr 2018 18:35

Thank you for the detailed steps. We have reproduced the issue and are investigating it. We will notify you about the results.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Navigator naming

Post by Shalex » Thu 19 Apr 2018 16:59

That is a designed behavior, because both CFG_FORM_CFG_FORM_ID_WITH_DETAILS and CFG_FORM_CFG_FORM_ID reference the same tables. This behavior was implemented basing on the previous customer requests. The names would be short (CFG_FORM and CFG_FORM1) if the second FK references a different table (not CfgForm).

Post Reply