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

Support JSON properties with TPT/TPC inheritance mapping #28443

Open
Tracked by #22953
maumar opened this issue Jul 13, 2022 · 8 comments
Open
Tracked by #22953

Support JSON properties with TPT/TPC inheritance mapping #28443

maumar opened this issue Jul 13, 2022 · 8 comments
Assignees
Labels
area-json consider-for-current-release punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-enhancement
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Jul 13, 2022

Currently only TPH inheritance is supported.

@ajcvickers ajcvickers added this to the 7.0.0 milestone Jul 28, 2022
@ajcvickers ajcvickers changed the title Json: allow TPT/TPC mapping if only the most derived type contains json-mapped entities Support JSON properties with TPT/TPC inheritance mapping Aug 30, 2022
@ajcvickers ajcvickers added the punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. label Aug 30, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, Backlog Aug 30, 2022
@mahdishahbazi
Copy link

mahdishahbazi commented Nov 26, 2022

Hi @maumar, @AndriySvyryd and @ajcvickers . Do we have a timeline for this?

@roji
Copy link
Member

roji commented Nov 26, 2022

@mahdishahbazi this is being considered for the 8.0 release, but it may or may not make it in.

@niltor

This comment was marked as resolved.

1 similar comment
@VoronkoVK

This comment was marked as resolved.

@roji

This comment was marked as resolved.

@douglasg14b
Copy link

douglasg14b commented Feb 12, 2024

The docs for TPC strategy really need to list all these limitations as a big warning! It's quite painful to find out that feature x, y, and z is not supported when using TPC or hierarchies in general, AFTER designing around it.

I hope these features exist eventually, but for now guiding users away from the feature when they're just gonna cause themselves pain seems prudent.

@JasonLandbridge
Copy link

A workaround, or how it has traditionally been done:

public class BaseClassConfiguration : IEntityTypeConfiguration<BaseClass>
{
    public void Configure(EntityTypeBuilder<BaseClass> builder)
    {
        builder.UseTpcMappingStrategy();

        builder
            .Property(b => b.JsonProperty)
            .HasConversion(
                x => JsonSerializer.Serialize(x, JsonSerializerOptions.Default),
                x => JsonSerializer.Deserialize<SomeType>(x, JsonSerializerOptions.Default))
            .IsUnicode();
    }
}

This does mean you can't query and index the JSON values within but at least you can store it.

@onionhammer
Copy link

Every time I turn around there's another limitation I bumped into

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-json consider-for-current-release punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. type-enhancement
Projects
None yet
Development

No branches or pull requests

10 participants