I am using Table Per Hierarchy TPH in Entity Framework, which is basically a partial class for common core attributes to the extended data types.
I have 2 Objects/Classes; Course
Object and a Student
Object which share the same base properties as the MyBaseCommonEntity
. The goal is to be able to perform a Service/ticket
on either of the objects. I need help in modeling this, will this be a generic type or inheritance type?
My questions: I am using int to refer to a parentID. The pK Key of the table is also an int.
- How can I prevent cyclic references
- Is this check done while setting
- Does Hierarchy id type give me this functionality by default?
What is the difference between table per type vs table per hierarchy vs table per class`
public partial class MyBaseCommonEntity { public int Id { get; set; } //Does it have any parents, does it belong to anyone public int? ParentId { get; set; } public string Name { get; set; } public string Description { get; set; } public System.DateTime CreatedDate { get; set; } public System.DateTime StartDate { get; set; } public System.DateTime? EndDate { get; set; } // Audit Stuff, whom, when why? public System.DateTime? AuditDate { get; set; } public string AuditUser { get; set; } public string AuditComments { get; set; } }