© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
11 replies
schwartzmj

❔ Polymorphic relationships in EF Core / .NET Core

I'm creating a spreadsheet-like app. At its most simple, I'm just displaying rows of models in a spreadsheet and letting the user update specific cells (columns).

I also need to implement a "highlight cell" feature. In something like Laravel, I'd create a polymorphic relationship. I imagine having a model called
Flag
Flag
with its table being
Flags
Flags
and columns being something like
Id
Id
,
FlaggableId
FlaggableId
, and
FlaggableType
FlaggableType
(along with a few other fields holding data specific to the flag like what type of flag it is or notes on the flag).
FlaggableType
FlaggableType
points to the model (table) and
FlaggableId
FlaggableId
points to the row of that table.

The 2nd bit of complexity here is I also need to store the column that I'm flagging (highlighting), something like
FlaggableColumn
FlaggableColumn
.

Is this also something I can do in .NET? Any guidelines or tips on where to start with creating the model for this? I've read a few things about
Discriminators
Discriminators
and TPH, TPT, and TPC. I'm a bit of a beginner in C# and .NET land and a few of the posts I found on the internet are a bit over my head.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ ASP.NET API (EF Core) Relationships
C#CC# / help
4y ago
Polymorphic query handling in EF Core - Thoughts?
C#CC# / help
3y ago
Help with EF Core polymorphic associations
C#CC# / help
2y ago
❔ EF Core Code-first relationships
C#CC# / help
4y ago