-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Configuring TPH with Enum Discriminator Throws InvalidOperationException #18769
Comments
Likely duplicate of #15553 |
@ajcvickers I saw that issue. In my opinion, I wouldn't classify this as a duplicate. #15553 is an issue with relationships between two hierarchies, while this is a just a single hierarchy and the issue is based around the discriminator name and the order of configuration. I have a repro which demonstrates the bug without any other entities than those above, so I'm 100% sure this isn't caused by relationships between hierarchies like #15553. It appears to be strictly the name of the discriminator combined with configuring the derived type first. The fix for one may fix the other, but I wouldn't say they're the same issue. |
Doesn't repro in 3.1.1 |
There appears to be a bug when configuring by implementing
IEntityTypeConfiguration<TEntity>
... order should not matter. Otherwise theApplyConfigurationsFromAssembly(...);
method can/will throw exception.An
InvalidOperationException
is thrown with messageThe property 'Discriminator' cannot be added to type 'Base' because the type of the corresponding CLR property or field 'Direction' does not match the specified type 'string'.
This only happens when configuring a derived type before the base type and when using a property named "Discriminator" as the discriminator (below -
Base.Discriminator
)Entities:
Configuration:
Steps to reproduce
Work-Arounds:
Further technical details
EF Core version: 3.0.0
Database provider: (Npgsql - 3.0.1)
Target framework: (.NET Core 3.0)
StackTrace
The text was updated successfully, but these errors were encountered: