-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Support IDictionary navigation property for one-to-many relationship #21262
Comments
While modelling similar relationship using existing capabilities I realized some difficulties of using The key of dictionary might be used in two ways:
Both 1. and 2. also require a |
This is a specific case of #2919 |
My model uses field Children being (subtype of)
IDictionary<child_key, Child>
to express one-to-many relationship Parent-Child and supporting easy/fast access to children items.I would like EF Core to support this pattern in similar way
ICollection<Child> Children
is handled.Consider
this throws exception
and adding conversion specification like this:
doesn't help either.
I also found this question asking for similar feature with a number of hack solutions (https://stackoverflow.com/questions/60726966/ef-core-use-a-dictionary-property), none of them is really addressing the problem though.
When the property is (sub)type of
ICollection<Child>
, then it's treated as navigational property, with migrations it creates ParentId property in Child table, etc. With IDictionary and appropriate information about keys it could work in similar way and even keep better performance for some tracking operations.The text was updated successfully, but these errors were encountered: