I want to make three table:
Tasks
- that table store informations as Ids, Names, Priority of tasks TakenTasks
- in this table we store user's ID that take tasks with DateTime EndedTasks
- Task that end with DateTime of end My question is, how to make in EntityFramework Core
table TakenTasks
and EndedTasks
have the same propertys mapped to Tasks
table without rewriteing code for Ids of tasks, name of tasks etc?
Tasks
table can be build based on abstract Task
class because i want to have object of Task
in list. What is the best solution for scenerio as i mentioned above?
public class Task
{
int Id { get; set; }
string Name { get; set; }
Priority Priority { get; set; }
}
public class TakenTask
{
string UserId { get; set; }
DateTime DateOfTaken { get; set; }
}
public class EndedTask
{
DateTime DateOfEnd { get; set; }
}
How to store information from Task
in TakenTask
and EndedTask
withotu rewriting propertys from Task
and have 3 tables ?
You don't need to duplicate the columns in three tables, use a foreign key from TakenTasks
and EndedTasks
to Task
and you can create a public virtual Task ParentTask{ get; set; }
public virtual Task ParentTask{ get; set; }
public virtual Task ParentTask{ get; set; }
in both TakenTasks
and EndedTasks
so you can access the Task properties
I think you need 2 tables:
Task
Assign
In Task
should have
int Id { get; set; }
string Name { get; set; }
Priority Priority { get; set; }
Status Status { get; set; }
In Assign
should have
int TaskId { get; set; }
int UserNameId { get; set; }
DateTime StartDate { get; set; }
DateTime EndDate { get; set; }`
Hope this help
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.