EF 6 - edmx error due to many to many relationship

Posts   
 
    
Shafeeq
User
Posts: 2
Joined: 26-Jan-2019
# Posted on: 26-Jan-2019 11:46:47   

Hello, were testing generating edmx file (using dbcontext api preset), and are having issue with scenario where an entity has many to many relationship with itself (through intermediary table), the generated edmx when used in projects shows the following error

error 0074: NavigationProperty is not valid. The FromRole and ToRole are the same.

Below the line in the edmx which is causing the probelm <NavigationProperty Name="RoleCollectionViaRolesRole" Relationship="Self.Role_RoleCollectionViaRolesRole_Role_RoleCollectionViaRolesRole_" FromRole="Role" ToRole="Role" />

To further elaborate, below the an example of tables and relations involved (e.g. idea is that each role can have multiple sub roles): Main Table: Roles Relationship table (RolesRole) - only has two columns ParentRoleId and ChildRoleId Relationships: Roles 1:m RoleRoles (Parent Rlateionship) Roles 1:m RoleRoles (For Child Relationship)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 27-Jan-2019 09:15:24   

What's the designer version you're using? If it's not 5.5.1, have you tried the latest build? If possible could you attach the project? If not, please open a helpdesk thread and attach it there so we can have a look.

Frans Bouma | Lead developer LLBLGen Pro
Shafeeq
User
Posts: 2
Joined: 26-Jan-2019
# Posted on: 27-Jan-2019 11:10:25   

its latest version is 5.5.1 (trial version), attached sample project.

Attachments
Filename File size Added on Approval
EdmxTestProject.llblgenproj 16,226 27-Jan-2019 11:10.37 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Jan-2019 07:26:07   

Reproduced it. We will look into it.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 28-Jan-2019 12:05:59   

As you're a trial user and can't download hotfixes, could you try the attached template?

Copy it into the folder (as administrator, overwriting the existing one) <llblgen installation folder>\Frameworks\Entity Framework\Templates\Shared\Shared

then regenerate the code, it should solve the issue.

As you're still in the startup of you project, it might be a good idea to choose as output to generate code first code instead of dbcontext + edmx (unless you need the features not supported through EF6 code first), as edmx has some limitations in inheritance hierarchies (if you use these).

Attachments
Filename File size Added on Approval
edmxFileInclude.lpt 43,914 28-Jan-2019 12:06.10 Approved
Frans Bouma | Lead developer LLBLGen Pro