EF Core 1-1 relationship with automatic discriminator
I have a
now, I would like a way to easily find what the comments thread belongs to. Does it contain comments of a blogpost? User profile? Document?
One way I figured was to reverse the relationship, and instead have a bunch of nullable FKs in the
but it all seems iffy at best.
Ideally, what I would like instead, was some
properties on the
Problem is, I have nary a clue how to do that. I considered maybe computed columns, but they seemingly can only reference the current entity.
CommentsThread entity and multiple ICommentable entities (Blogpost, Profile, Document, etc.) that all reference it:now, I would like a way to easily find what the comments thread belongs to. Does it contain comments of a blogpost? User profile? Document?
One way I figured was to reverse the relationship, and instead have a bunch of nullable FKs in the
CommentsThread entity, pointing to all the ICommentables. That way, I could do somebut it all seems iffy at best.
Ideally, what I would like instead, was some
properties on the
CommentsThread, with CommentsSource being an enum.Problem is, I have nary a clue how to do that. I considered maybe computed columns, but they seemingly can only reference the current entity.
