none
The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical. RRS feed

  • Question


  • 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 problem:

    Aula_Agenda_Target_Aula_Agenda_Source:: The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical.



    The class is:

    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; }
        }


    Your Mapping:

    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("Agenda");
                this.Property(u => u.AulaID).HasColumnName("AulaID");
                this.Property(u => u.AgendaID).HasColumnName("AgendaID");
                this.Property(u => u.UsuarioID).HasColumnName("UsuarioID");
    
    
                // 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);
            }
        }

    DBDiagram:
    https://github.com/dicataldisky/DACSistemas.Central-de-Cursos.BackEnd/blob/master/DBDiagram.pdf

    The Project Code is in github:
    https://github.com/dicataldisky/DACSistemas.Central-de-Cursos.BackEnd

    Please help me .. I do not know what to do!

    Thank you


    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 problem: Aula_Agenda_Target_Aula_Agenda_Source:: The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical. The class I am using is: Your Mapping: The Project Code is in github: Please help me .. I do not know what to do! Thank you
    Saturday, July 7, 2018 6:38 AM

Answers

  • I'm working with WEB API 2 with EF6

    https://forums.asp.net/

    it is  where you should post.                                                                                                                                                                                                                                                                                                                     

    Saturday, July 7, 2018 1:05 PM