User920949512 posted
Hello everyone!
I would like your help in a project I am developing for a free flight school ...
I'm working with WEB API 2 with EF6
I was able to write a good part of the code but now I have this exception:
One or more validation errors were detected during model generation:
Aula_Agenda_Target_Aula_Agenda_Source: : The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical.
My Aula Class:
public class Aula
{
public Aula()
{
}
//Primary Key
public int AulaID { get; set; }
//Fields
public int UsuarioID { get; set; }
public int AgendaID { get; set; }
public DateTime Entrada { get; set; }
public DateTime Saida { get; set; }
//Virtual Properties
public virtual Usuario Usuario { get; set; }
public virtual Agenda Agenda { get; set; }
}
My Agenda Class:
public Agenda()
{
Aulas = new List<Aula>();
}
// Primary Key
public int? AgendaID { get; set; }
// Fields
public int CursoID { get; set; }
public int UsuarioID { get; set; }
public int EnderecoID { get; set; }
public string Descricao { get; set; }
public DateTime? Inicio { get; set; }
public DateTime? Termino { get; set; }
public Curso Curso { get; set; }
public Usuario Usuario { get; set; }
public Endereco Endereco { get; set; }
public virtual ICollection<Aula> Aulas { get; set; }
}
My Aula MAP:
public class AulaMap : EntityTypeConfiguration<Aula>
{
public AulaMap()
{
// Primary Key
this.HasKey(k => new { k.AulaID, k.UsuarioID, k.AgendaID });
// Properties
// Table & Collumn Mappings
this.ToTable("Aula");
this.Property(u => u.AulaID).HasColumnName("AulaID");
this.Property(u => u.AgendaID).HasColumnName("AgendaID");
this.Property(u => u.UsuarioID).HasColumnName("UsuarioID");
this.Property(u => u.Entrada).HasColumnName("Entrada");
this.Property(u => u.Saida).HasColumnName("Saida");
// Relationships
this.HasRequired(r => r.Usuario).WithMany(d => d.Aulas).HasForeignKey(fk => fk.UsuarioID);
this.HasRequired(r => r.Agenda).WithMany(d => d.Aulas).HasForeignKey(fk => fk.AgendaID);
}
}
My DbDiagram:
https://github.com/dicataldisky/DACSistemas.Central-de-Cursos.BackEnd/blob/master/DBDiagram.pdf
My Project on GITHUB:
https://github.com/dicataldisky/DACSistemas.Central-de-Cursos.BackEnd
Please Help Me!