EF core generated code does not contain a definition for 'HasDiscriminator'
I was following course on YouTube:
https://www.youtube.com/playlist?list=PLzYkqgWkHPKBcDIP5gzLfASkQyTdy0t4k
I use this repos as reference to read the code
https://github.com/PanKunik/buber-dinner
After i update all dependency to net8.0: I encounter this error:
GitHub
GitHub - PanKunik/buber-dinner: This repository follows Amichai Man...
This repository follows Amichai Mantinband course on REST API DDD CLEAN ARCHITECTURE. - PanKunik/buber-dinner
7 Replies
The code look almost identical
HasDiscriminator
is a method on EntityTypeBuilder
.
b1
is an OwnedNavigationBuilder
would you like to elaborate?
:TeBeCat:
You're attempting to use
HasDiscriminator
in the wrong context. It is something you would use when you're configuring an entity, not a relationship.
modelBuilder.Entity<SomeType>(b => b.HasDiscriminator(...))
Not sure if there is an easy way to handle discriminators when configuring owned entities.https://github.com/dotnet/efcore/issues/29659 a relevant github issue, not sure if there's been much done to make this easier
GitHub
HasDiscriminator based on owned value object property · Issue #2965...
Question How would I go about configuring a discriminator column based on a property of an owned (OwnsOne) type? Code public record ClassDetails(ClassType Type); public abstract class BaseClass { p...
To be honest, I lack of knowledge about ef-core configuration . I just understand what course's author archives, however i never configure efcore before. I suppose it working like previous efcore version 7.
I'd recommend spending some time to learn EF, it can be pretty confusing if you have no clue what's going on.