Skip to content
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

Duplicate property names when having multiple many-to-many relationships using composite keys #465

Closed
aeslinger0 opened this issue Sep 28, 2018 · 2 comments

Comments

@aeslinger0
Copy link

I apologize if this issue exists already somewhere, but I couldn't find it.

I have two tables that represent many-to-many relationships between tables "Users" and "Skills". One for "required" skills and one for "preferred" skills. Each has a composite primary key using UserId, SkillId

CREATE TABLE [dbo].[UserRequiredSkill] (
    [UserId]    INT NOT NULL,
    [SkillId]     INT NOT NULL,
    CONSTRAINT [PK_UserRequiredSkill] PRIMARY KEY CLUSTERED ([UserId], [SkillId]),
    CONSTRAINT [FK_UserRequiredSkill_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_UserRequiredSkill_Skill] FOREIGN KEY ([SkillId]) REFERENCES [dbo].[Skill] ([SkillId])
);

CREATE TABLE [dbo].[UserPreferredSkill] (
    [UserId]    INT NOT NULL,
    [SkillId]     INT NOT NULL,
    CONSTRAINT [PK_UserPreferredSkill] PRIMARY KEY CLUSTERED ([UserId], [SkillId]),
    CONSTRAINT [FK_UserPreferredSkill_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([UserId]),
    CONSTRAINT [FK_UserPreferredSkill_Skill] FOREIGN KEY ([SkillId]) REFERENCES [dbo].[Skill] ([SkillId])
);

However, the user table generates duplicate properties:

/// <summary>
/// Child Skills (Many-to-Many) mapped by table [UserPreferredSkill]
/// </summary>
public System.Collections.Generic.ICollection<SkillEntity> Skills_SkillId { get; set; } // Many to many mapping
/// <summary>
/// Child Skills (Many-to-Many) mapped by table [UserRequiredSkill]
/// </summary>
public System.Collections.Generic.ICollection<SkillEntity> Skills_SkillId { get; set; } // Many to many mapping

The skills table also has duplicate properties. Why is this? Couldn't it just use the pluralized many-to-many table names for the property names? As in:

public System.Collections.Generic.ICollection<SkillEntity> UserRequiredSkills { get; set; }
public System.Collections.Generic.ICollection<SkillEntity> UserPreferredSkills { get; set; }

Am I doing something wrong or is there a way to override this behavior so the code compiles?

@sjh37 sjh37 closed this as completed in #466 Oct 2, 2018
sjh37 added a commit that referenced this issue Oct 2, 2018
Resolves #465 for many to many relationships to rename the property names. Thanks to jbaig
@sjh37
Copy link
Owner

sjh37 commented Oct 2, 2018

Released v2.37.2

@aeslinger0
Copy link
Author

Upgraded and saw the comment in the commit. It works. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants