I'm working on a database-first project with an existing database where I can not change the schema.
The database design uses TPH inheritance where there are parents and childs in the same table. The childs have the Id of the matching parent as a "ParentId"-Column.
To distinguish between parent and child there is the "Type"-Column. This database design uses a string as the discriminator for the childs and nothing (null) for the parents.
When describing the inheritance with
entity.HasDiscriminator(t => t.Type)
.HasValue<Foo>("Foo")
.HasValue<Bar>("");
I get the exception:
Unable to materialize entity instance of type 'Bar'. No discriminators matched the discriminator value ''.
What would be the smartest way to implement this in EF Core without changes to the database?