© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•17mo ago•
30 replies
Saiyanslayer

✅ Designing a configurable object in EF Core

Hi everyone!

My goal is to have an object for a web project where you can configure the fields it has:
public class Structure {
   public int Id;
   public string Name;
   public Property[] Properties; // each value to show/edit
   public Structure[] Structures; // in the future, can also contain other Structure objects
}

public class Property<TValue> {
   public int Id;
   public string Name;
   public T Value;
}
public class Structure {
   public int Id;
   public string Name;
   public Property[] Properties; // each value to show/edit
   public Structure[] Structures; // in the future, can also contain other Structure objects
}

public class Property<TValue> {
   public int Id;
   public string Name;
   public T Value;
}


This would let me design a "Patient" object:
new Structure(Id:"1", Name:"Patient")
new Structure(Id:"1", Name:"Patient")


I could add properties:
var properties = {
  new Property<string> {Id = 1, Name = "Patient Name", Value = "John Doe"},
  new Property<string> {Id = 2, Name = "Patient Id", Value = "007"},
  new Property<DateTime> {Id = 3, Name = "Patient Birthday", Value = "2024-09-22"}
}
var properties = {
  new Property<string> {Id = 1, Name = "Patient Name", Value = "John Doe"},
  new Property<string> {Id = 2, Name = "Patient Id", Value = "007"},
  new Property<DateTime> {Id = 3, Name = "Patient Birthday", Value = "2024-09-22"}
}


What would be a good approach in EF Core to this? Table-Per-Hierarchy? How can I map the TValue generic properly?
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

EF Core
C#CC# / help
2y ago
❔ Polymorphic relationships in EF Core / .NET Core
C#CC# / help
3y ago
EF Core - Where clause on multiple field in object list
C#CC# / help
2y ago
✅ EF core transactions in PostgreSQL
C#CC# / help
2y ago