Skip to content

InvalidOperationException when mapping properties of different types to the same column #29859

@AndriySvyryd

Description

@AndriySvyryd

Class A: BaseClass

[Column(nameof(Configuration), TypeName = "jsonb")]
public ConfigurationForClassA Configuration { get; set; } = new();
Class B: BaseClass

[Column(nameof(Configuration), TypeName = "jsonb")]
public ConfigurationForClassB Configuration { get; set; } = new();
This worked in .NET 5&6 (with Ef Core 5/6) by re-using the column in the baseclass table. Breaks after upgrading to .NET 7 and EF7.

are both mapped to column 'Configuration' in 'BaseClassTable', but are configured to use differing provider types

I would assume that there is some conflict with the new json support in EF7, maybe there is some requirement to mark classes used in json columns in some way? e.g. with an [Owned] attribute?

Originally reported by @cm-andrews at npgsql/efcore.pg#2595

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions