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 mapping multiple types to the same JSON column (sharing) #28592
This doesn't cover cases where a discriminator value inside the JSON would be used. That would be covered by #27779 or #38059
Reacted by Oskar Klintrot, Steven Darby, Rafał Kwol, Sebastian, Materix, Dmytro Iavlianskyi, Moaz Alkharfan, rubytech-avsorokin, Chris Haws, meichhorn-conet and 298 more
Reacted by AL.exe, vangansewinkelb, Santiago, codelovercc, Hanna, Jono Williams, Elvijs Teikmanis, Oskar Klintrot, witaway, Cristian Florea and 35 more
Reacted by Lucas Maximiliano Marino, Brandon seydel, JustQrtZ, ZzZombo, JC Mata, Martin Indzhov, johnhwright, Siarhei Kavaleuski, Shimmy Weitzhandler, Calvin Agar and 1 more
Reacted by Lucas Maximiliano Marino, Brandon seydel, JustQrtZ, JC Mata, johnhwright, Siarhei Kavaleuski, Shimmy Weitzhandler, Calvin Agar and mavduck
This issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 8.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. Make sure to vote (👍) for this issue if it is important to you.
Please keep on voting for this issue so it might get prioritized for v9! 👍
With TPH this would make for a very powerful storage of metadata for similar, yet different, entities. Now the database would get flooded with columns like MetadataJsonA, MetadataJsonB, MetadataJsonC for each entity in the hierarchy. Once this gets implemented however, I imagine it will be easy to consolidate all columns to a single MetadataJson column.
Reacted by Oskar Klintrot, codelovercc, Alexander, c5racing, dawidszwajkowski, Arnaud, Simon Chester, Boris Siljanovski, Alister Pineda, Samuel Janek and 53 more
Keep voting people, this is definitely an important feature that actually opens many uses cases for json columns, does anyone know if there is a workaround?
Reacted by codelovercc, Oskar Klintrot, Diego Bonura, Michael Gruber, Kostas Rontogiannis, Bram Musters, Jared Haight, DaKaLKa, Fabio Vides F, Dan Kokotov and 12 more
This would be an exiting thing! I a certain project we store audit data of other Tables in auditlog table as json string and in another column we store the table name. One for old valua one for new new value. The json string is generated is overriden SaveChanges methode, This works very very well and allows to even display the changed values.
However, reading this column back into object is currently painful and requires a rather long if / else sequence to create the typed object.
Hopefully there will be a more general solution to this.
Note #27779, which is also about mapping multiple types to the same JSON document (or sub-document), but where the types are in a hierarchy - also via the use of a discriminator ($type). We may want to implement these two features together.
Note also that we already allow mapping unrelated entity types to the same container in Cosmos with a discriminator property (but not sub-documents).
Reacted by Yann Zahringer Ferrando, dszwajkowski, Lucas Maximiliano Marino, Pouria Riyahi, sprengo, Alexander Trauzzi, Kir, Felix Strauß, Leonardo and Marcel Bradea
I vote this up as well... definitely use multi-structured json objects for sub-entity details a lot these days. Manually configuring the conversion (see example below) seems to produce what I need, upside is I get to define the serialize options specifically as well... feature request #28043
modelBuilder.Entity<EquipmentPricingItem>()
.Property(e => e.PricingDetail)
.HasColumnName("PricingDetail")
.HasConversion(
v => JsonSerializer.Serialize(v, _jsonOptions),
v => JsonSerializer.Deserialize<EquipmentPricingDetail>(v, _jsonOptions)
);
modelBuilder.Entity<ProductPricingItem>()
.Property(e => e.PricingDetail)
.HasColumnName("PricingDetail")
.HasConversion(
v => JsonSerializer.Serialize(v, _jsonOptions),
v => JsonSerializer.Deserialize<ProductPricingDetail>(v, _jsonOptions)
);
changed the title [-]Support mapping multiple owned types to the same JSON column (sharing)[/-][+]Support mapping multiple types to the same JSON column (sharing)[/+]on Apr 7, 2026
Activity
ajcvickers commentedon Nov 4, 2022
This is not easy, but would enable some interesting and useful scenarios--see #29456.
codelovercc commentedon Sep 12, 2023
@ajcvickers Hi, I am so excited about this feature. Any news? Will this be supported in Entity Framework Core 8 (EF Core 8; EF8) ?
ajcvickers commentedon Sep 12, 2023
This issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 8.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. Make sure to vote (👍) for this issue if it is important to you.
joakimriedel commentedon Dec 12, 2023
Please keep on voting for this issue so it might get prioritized for v9! 👍
With TPH this would make for a very powerful storage of metadata for similar, yet different, entities. Now the database would get flooded with columns like MetadataJsonA, MetadataJsonB, MetadataJsonC for each entity in the hierarchy. Once this gets implemented however, I imagine it will be easy to consolidate all columns to a single MetadataJson column.
uabarahona commentedon May 24, 2024
Keep voting people, this is definitely an important feature that actually opens many uses cases for json columns, does anyone know if there is a workaround?
digitalsigi commentedon Aug 7, 2024
This would be an exiting thing! I a certain project we store audit data of other Tables in auditlog table as json string and in another column we store the table name. One for old valua one for new new value. The json string is generated is overriden SaveChanges methode, This works very very well and allows to even display the changed values.
However, reading this column back into object is currently painful and requires a rather long if / else sequence to create the typed object.
Hopefully there will be a more general solution to this.
elementh commentedon Aug 17, 2024
This would be game changing, honestly!
roji commentedon Aug 17, 2024
Note #27779, which is also about mapping multiple types to the same JSON document (or sub-document), but where the types are in a hierarchy - also via the use of a discriminator ($type). We may want to implement these two features together.
Note also that we already allow mapping unrelated entity types to the same container in Cosmos with a discriminator property (but not sub-documents).
atrauzzi commentedon Oct 5, 2024
Custom discriminator field!
andreiolaru commentedon Nov 22, 2024
Is this feature considered?
fspataro commentedon Dec 20, 2024
I vote this up as well... definitely use multi-structured json objects for sub-entity details a lot these days. Manually configuring the conversion (see example below) seems to produce what I need, upside is I get to define the serialize options specifically as well... feature request #28043
weitzhandler commentedon Jul 9, 2025
@fspataro I wonder if the column type can be
jsonb.[-]Support mapping multiple owned types to the same JSON column (sharing)[/-][+]Support mapping multiple types to the same JSON column (sharing)[/+]