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

ForeignKeyConvention doesnt run when dependent entity type PK is changed #11019

Closed
maumar opened this issue Feb 21, 2018 · 0 comments
Closed
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Feb 21, 2018

Before:

    public class LocustLeader
    {
        public string Name { get; set; }
        public short ThreatLevel { get; set; }
    }

    public class LocustCommander : LocustLeader
    {
        public LocustHorde CommandingFaction { get; set; }

        public string DefeatedByNickname { get; set; }
        public int? DefeatedBySquadId { get; set; }
        public Gear DefeatedBy { get; set; }
    }

    public abstract class Faction
    {
        public int Id { get; set; }
        public string Name { get; set; }

        public string CapitalName { get; set; }
        public City Capital { get; set; }
    }

    public class LocustHorde : Faction
    {
        public LocustCommander Commander { get; set; }
        public List<LocustLeader> Leaders { get; set; }

        public string CommanderName { get; set; }
        public bool? Eradicated { get; set; }
    }

and OnModelCreating:

modelBuilder.Entity<LocustHorde>().HasOne(h => h.Commander).WithOne(c => c.CommandingFaction);

would create a navigation: locustHorde.CommanderName -> locustLeader.Name

After adding (undelated) navigation to LocustCommander, the relationship is not defined as:
faction.Id -> locustLeader.CommandingFactionId

The new definition is worse because the navigation is declared on derived entity - LocustHorde and there is a matching FK (CommanderName)

@ajcvickers ajcvickers added this to the 2.1.0 milestone Feb 21, 2018
AndriySvyryd added a commit that referenced this issue Feb 28, 2018
Run ForeignKeyPropertyDiscoveryConvention when the PK is changed.

Fixes #9180
Fixes #11019
AndriySvyryd added a commit that referenced this issue Feb 28, 2018
Run ForeignKeyPropertyDiscoveryConvention when the PK is changed.

Fixes #9180
Fixes #11019
AndriySvyryd added a commit that referenced this issue Feb 28, 2018
Run ForeignKeyPropertyDiscoveryConvention when the PK is changed.

Fixes #9180
Fixes #11019
@AndriySvyryd AndriySvyryd removed their assignment Feb 28, 2018
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Feb 28, 2018
@ajcvickers ajcvickers modified the milestones: 2.1.0-preview2, 2.1.0 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

3 participants