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

Allow shared object (no Foreign Key) relationships #14260

Closed
jhandel opened this issue Dec 28, 2018 · 1 comment
Closed

Allow shared object (no Foreign Key) relationships #14260

jhandel opened this issue Dec 28, 2018 · 1 comment

Comments

@jhandel
Copy link

jhandel commented Dec 28, 2018

I run in to a number of situations where I want to share an object type across multiple parents.. Could be a Contact, Address, Image&MetaData. I would like support for a "shared" entity.. one that is based on a parent ID and discriminator.. While navigating from the child (Contact, address, image, etc) to the parent would be non-trivial, the vast majority of the time this use case is from the parent to a collection of children. Currently without adding a bunch of one off inherited objects and a nullable FK for each parent type this is not doable, and that approach is disliked by many a DBA..

Ideal use case:
Contact:

  • Id
  • ParentId
  • ParentDiscriminator
  • [the rest of the fields that make up a contact]

Customer:

  • Id
  • Fields that make up a customer
  • ICollection Contacts

Supplier:

  • Id
  • Fields that make up a supplier
  • ICollection Contacts

Partner:

  • Id
  • Fields that make up a partner
  • ICollection Contacts

Warehouse:

  • Id
  • Fields that make up a partner
  • ICollection Contacts

etc... Currently the best I can do is create a ContactBase, then a contact per parent, and that adds an FK per parent to the database model. And that approach just seems overly complicated, causes code bloat (if a contact is truly is identical every time) and adds fields and un-needed indexes to the database.

Thanks

@ajcvickers
Copy link
Member

From our best understanding this looks like an example of mapping interfaces with polymorphic associations, which is tracked by #757

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

2 participants