You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support inheritance for owned/property bag/shared-type entity types #9630
This is ambiguous as to whether LessThanFriend.CityAddress should be mapped to allow inheritance such that either a CityAddress or a FullAddress could be persisted. Typically, we only map inheritance when both types are in the model. However, having both types in the model as Owned types on different entities perhaps does not have the same semantics--especially when thinking of them like complex types.
Based on triage discussion from #9536, we think we want to support both the simple mapping (just persisting given concrete type, which is what the request on #9536 is for) and the inheritance mapping, which would require, for TPH, and additional discriminator column in the table. We did not come to a final decision on which should be the default, or what the new API will look like to switch between the two.
I am having a problem in which a owned type generates a Discriminator property, even though there is no need for it, since the class that has this property is not derived anywhere else.
Can this be the same issue?
I tried removing it from migration and from the snapshot to test, but it generates a wrong sql statement when acessing the DbContext on that Set.
Is there any way to get around this, without generating the property on the database?
@chris-stormideas We understand what this issue is about--i.e. inheritance mapping into a shared table is not supported. The feature is currently on the backlog, and not considered very high priority. The best way to influence getting it resolved is probably to make a case for why this specific mapping is so important.
Reacted by Chris Canal, Steve "Ardalis" Smith and Gertjan van de Ree
Polymorphic owned collections do provide the ability to compose our object model which is really quite nice.
From my perspective having to define all the derived types explicitly isn't a problem at all.
Do you guys have an idea when this issue might bubble up in the backlog?
I have a project I have been waiting to migrate over to efcore that currently uses Horrible InHouse Awful ORM (tm) that I wrote years ago much to today me's regret. This is the only feature left that I cant really support with efcore.
Thanks for the feedback. If polymorphic owned collections are covered by this issue, I would recommend updating the issue title+description so that users can find this. ATM it is not really clear and looks like it only covers inline owned types. Thanks!
is any input needed to help decide if this makes the cut for the current release? It is still the only thing preventing me from migrating to efcore and I very much want to :)
Reacted by Bohdan Yarchak, David Makovský, ericguin, danfaber, Greg Zapp and Samson Nwizugbe
Are there any updates regarding this topic ? I feel like this feature is missing so much, specially today when usage of DDD becoming more and more popular. I really looking forward to see this feature in EF core 10 !
Reacted by Pavel Voronin, 0x6A6F73, huberttrueselftrueme, Tomasz Malinowski, Aleksandar Jovanov, Andre Rodi, Dante De Ruwe, Grégoire Wulliamoz, Shimmy Weitzhandler, Alexander Lykke Lademann Østergaard and 12 more
Activity
AndriySvyryd commentedon Jan 31, 2018
We would need API on
ReferenceOwnershipBuilderto declare the derived types.Related to #10140
andre-f-paggi commentedon Sep 17, 2018
It took me so much time to get to this issue.
I am having a problem in which a owned type generates a Discriminator property, even though there is no need for it, since the class that has this property is not derived anywhere else.
Can this be the same issue?
I tried removing it from migration and from the snapshot to test, but it generates a wrong sql statement when acessing the DbContext on that Set.
Is there any way to get around this, without generating the property on the database?
ajcvickers commentedon Sep 17, 2018
@andre-f-paggi Please file a new issue and include a runnable project/solution or complete code listing that demonstrates the behavior you are seeing.
chris-stormideas commentedon Feb 28, 2019
@ajcvickers I can look at supplying a runnable solution if it will assist getting it resolved quicker
ajcvickers commentedon Feb 28, 2019
@chris-stormideas We understand what this issue is about--i.e. inheritance mapping into a shared table is not supported. The feature is currently on the backlog, and not considered very high priority. The best way to influence getting it resolved is probably to make a case for why this specific mapping is so important.
davidroth commentedon Jan 16, 2020
@ajcvickers
What about collections of owned types, where the owned-collection is polymorphic?
For example:
Is this implicitly tracked by this issue or would you recommend creating a new issue for this?
ajcvickers commentedon Jan 16, 2020
@AndriySvyryd Thoughts on polymorphic owned collections?
AndriySvyryd commentedon Jan 16, 2020
Polymorphic owned collections will be covered by this, but similar to non-collections all derived types will need to be configured explicitly.
digitalpowers commentedon Jan 17, 2020
Polymorphic owned collections do provide the ability to compose our object model which is really quite nice.
From my perspective having to define all the derived types explicitly isn't a problem at all.
Do you guys have an idea when this issue might bubble up in the backlog?
I have a project I have been waiting to migrate over to efcore that currently uses Horrible InHouse Awful ORM (tm) that I wrote years ago much to today me's regret. This is the only feature left that I cant really support with efcore.
AndriySvyryd commentedon Jan 17, 2020
@digitalpowers For now we can only say that it won't happen this year.
davidroth commentedon Jan 17, 2020
Thanks for the feedback. If polymorphic owned collections are covered by this issue, I would recommend updating the issue title+description so that users can find this. ATM it is not really clear and looks like it only covers inline owned types. Thanks!
[-]Support inheritance for owned types mapped inline[/-][+]Support inheritance for owned types[/+]Lobosque commentedon Aug 25, 2020
@AndriySvyryd Does this issue also cover the case where I explicitly want to set a
HasDiscriminatorunder an owned entity?Example:
In this particular example,
AlertPatternis an abstract class andPatternOneand friends inherit it.25 remaining items
digitalpowers commentedon Feb 29, 2024
is any input needed to help decide if this makes the cut for the current release? It is still the only thing preventing me from migrating to efcore and I very much want to :)
chrisc-onaorg commentedon Oct 4, 2024
What's the chance we might see this in EF Core 9?
ErikEJ commentedon Oct 4, 2024
@chrisc-ona None - 9 is done
chrisc-onaorg commentedon Oct 4, 2024
@ErikEJ well hopefully we'll have it in 10 then
huberttrueselftrueme commentedon Mar 13, 2025
Are there any updates regarding this topic ? I feel like this feature is missing so much, specially today when usage of DDD becoming more and more popular. I really looking forward to see this feature in EF core 10 !
ricoprzybylski commentedon Feb 13, 2026
Is there any chance to see this in ef core 11 ?
AndriySvyryd commentedon Feb 13, 2026
@ricoprzybylski No, we are still resource constrained. I doubt this could be done before EF 13