Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyEntities : DbContext
- {
- public DbSet<Pessoa> Pessoas { get; set; }
- public DbSet<Endereco> Enderecos { get; set; }
- public MyEntities()
- : base("Repositorio") { }
- protected override void OnModelCreating(DbModelBuilder mb)
- {
- mb.Entity<Pessoa>()
- .HasMany(p => p.Enderecos)
- .WithMany(e => e.Pessoas)
- .Map(m => m.MapLeftKey("EnderecoId")
- .MapRightKey("PessoaId")
- .ToTable("Enderecos_Pessoas"));
- base.OnModelCreating(mb);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement