'EF multiple table referencing to same column C#
I have created an application with DB First approach in Asp.net Core. I have a table called Documents which has a column which refers to multiple tables and is identified by ApplicationType.
Documents Table
----------
ID
DocumentName
ApplicationType (Values Project, Task, Actions)
ApplicationId (FK References Id of the respective table for which the document is stored)
Projects
----------
Id
ProjectName
Columns....
Tasks
----------
Id
TaskName
Columns....
Actions
---------
Id
ActionName
Columns....
Now, I have the entity created as Documents with the properties for the fields and Collections for the child tables(Foreign Keys).
I want to create an entity class for this like an abstract Document with the properties and have child ProjectDocument, TaskDocument and ActionDocument which extend the Document entity class.
Is this possible? How can I write this and make sure when ProjectDocument is called, only project types will be fetched, similarly to others.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
