Create an alternate key for join entity types which have an independent PK

Open
#21,900 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

Start with the state manager's fixup path and how join entity types are identified, using the example in this issue as the target case. Review issue #4073 before designing the dependency. Done means join types with an independent primary key have an alternate key for the usual composite join values and support fast matching during fixup.

Written by the indexing model from the issue text.

Description

area-change-tracking area-many-to-many area-model-building area-perf

Consider this many-to-many join type:

public class JoinType
{
        public virtual Guid Id { get; set; }
        public virtual int LeftId { get; set; }
        public virtual int RightId { get; set; }
}

When performing fixup, the state manager needs to lookup instance where LeftId and RightId match. This fast when these types form the composite PK of the type. In this case Id is the PK, and hence there isn't a way to do a fast lookup for matches of LeftId and RightId.

To fix this, we should create an alternate key for what would usually be the PK in the join table. However, we should likely only do this after #4073 is implemented to avoid making it impossible to change these values, although it does seem unlikely that changing them would be useful.

Dominant language
C#
Stars
14.8k
Forks
3.4k
Avg merge
2d 5h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.