Foreign key Entity framework 6

Asked

Viewed 277 times

0

Someone can help me make a connection between these two tables, I want to use the enrollment field to make that call, and enrollment in the student table is not the primary key.

    public class Aluno
{
    [Key]
    public int  IdAluno { get; set; }

    [Required(ErrorMessage = "Escolha a escola!")]
    public int IdEscola { get; set; }

    [Required(ErrorMessage = "Digite a matrícula!")]
    public double matricula { get; set; }

    [Required(ErrorMessage = "Digite o nome do aluno!")]
    public string nome { get; set; }

    [Required(ErrorMessage = "Digite a senha do aluno!")]
    [DataType(DataType.Password)]

    public string senhaAluno { get; set; }

    [Required(ErrorMessage = "Digite a senha do responsável!")]
    [DataType(DataType.Password)]

    public string senhaResponsavel { get; set; }

    public virtual Escola escola { get; set; }
    public virtual ICollection<diarioAluno> diarioAluno { get; set; }
}

public class diarioAluno
{
    [Key]
    [Required]
    public int IdDiarioAluno { get; set; }

    [Required(ErrorMessage = "Escolha o diário!")]
    public int IdDiario { get; set; }


    [Required(ErrorMessage = "Digite a matrícula do aluno!")]
    public double matricula { get; set; }

    [Required(ErrorMessage = "Digite a ordem do aluno!")]
    public int ordem { get; set; }

    [Required(ErrorMessage = "Marque, caso o aluno não estiver mais nesse diário!")]
    public bool situacao { get; set; }

    public virtual Diario diario { get; set; }

    public virtual Aluno aluno { get; set; }

    public virtual ICollection<Falta> falta { get; set; }
    public virtual ICollection<Nota> notas { get; set; }


}
  • Enter the code not a photo of it so members can test it

  • OK ! Sorry, it’s my first post...

  • Solved the problem?

  • Yes, I solved that problem in another way. Thank you

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.