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

Use simple entity type for simple join tables #22000

Open
Tracked by #22960
ajcvickers opened this issue Aug 9, 2020 · 4 comments
Open
Tracked by #22960

Use simple entity type for simple join tables #22000

ajcvickers opened this issue Aug 9, 2020 · 4 comments

Comments

@ajcvickers
Copy link
Member

A Dictionary is overkill for a type that will only store two key properties, which is the common case for many-to-many with non-composite keys on either end. Instead, consider using:

public class JoinEntity<TLeft, TRight>
{
    public virtual TLeft LeftId { get; set; }
    public virtual TRight RightId { get; set; }
}
@roji
Copy link
Member

roji commented Aug 10, 2020

Another option is to simply use ValueTuple.

Note that there's a perf impact here as well, since Dictionary is much slower.

@ajcvickers
Copy link
Member Author

Note from triage: punt on this for now, but:

@willnationsdev
Copy link

Just out of curiosity, how is this proposal different from EntityTypeBuilder<TRightEntity> UsingEntity<TJoinEntity>(...)? I have scenarios where I map a simple entity to a many-to-many join table and that is already supported. I do, however, have to manually specify the left & right sides of the mapping entity's relationships, so is this about making that process automatic for Plain Old Data types?

@ajcvickers
Copy link
Member Author

@willnationsdev This is about changing the default.

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

No branches or pull requests

3 participants