I have the following classes:
[Table("Area_Cursos_Turma")]
public class Turma
{
public int TurmaID { get; set; }
public virtual ICollection<Aluno> Alunos { get; set; }
}
[Table("Area_Cursos_Aluno")]
public class Aluno
{
public int AlunoID { get; set; }
public virtual ICollection<Turma> Turmas { get; set; }
}
Using Migration
, it creates for me the table in the database: TurmaAluno
, and would like it to create Area_Cursos_TurmaAluno
.
I've tried the following:
modelBuilder.Entity<Aluno>()
.HasMany(t=>t.Turmas)
.WithMany(a => a.Alunos)
.Map(m => m.MapLeftKey("Turma_TurmaID")
.MapRightKey("Aluno_AlunoID")
.ToTable("Area_Cursos_TurmaAluno"));
Apparently it worked. Is that right?