I have the following problem: A client has tasks for each day of the week.
Example:
Customer A - Saturday - Car Wash, Clean House ...
Map as follows:
public class Cliente
{
[Key]
public int Id { get; set; }
[MaxLength(250)]
public string Nome { get; set; }
public virtual ICollection<DiaSemana> DiasSemana { get; set; }
}
public class DiaSemana
{
public DiaSemana()
{
Tarefas = new List<Tarefa>();
Clientes = new List<Cliente>();
}
[Key]
public int Id { get; set; }
[MaxLength(20)]
public string Dia { get; set; }
public virtual ICollection<Tarefa> Tarefas { get; set; }
public virtual ICollection<Cliente> Clientes { get; set; }
}
public class Tarefa
{
public Tarefa()
{
DiasSemana = new List<DiaSemana>();
}
[Key]
public int Id { get; set; }
[MaxLength(20)]
public string Nome { get; set; }
public virtual ICollection<DiaSemana> DiasSemana { get; set; }
}
When I started to popular the bank, using Entity Framework
, it became a mess and I started to see that Entity Framework
understood everything wrong rs ( EF
donkey rs) ...
I know the way I map is incorrect, but I can not figure out how I can map the classes correctly.
Edit:
EF has created the following tables:
Task
Id Nome
1 Lavar Louça
2 Limpar Casa
Weekday Task
Treafa_Id DiaSemana_Id
1 2
2 2
DiaSemana
Id Dia
1 Segunda
2 Terça
3 Quarta
DiaSemanaCustomer
DiaSemana_Id Cliente_Id
2 99
2 66
Customer
Id Nome
99 Diego
66 Felipe
In this case the bank is assuming that Diego and Felipe have both tasks. But Diego de Terça has only the task of Washing Dishes and Felipe only the task of Clean House.
In my understanding, I needed the client id in the TaskTableDaysheet