using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfiguration; namespace IntegrationTests.Models.Mapping { public class Company2ClientMap : EntityTypeConfiguration { public Company2ClientMap() { // Primary Key this.HasKey(t => t.Id); // Properties // Table & Column Mappings this.ToTable("Company2Client"); this.Property(t => t.Id).HasColumnName("Id"); this.Property(t => t.CompanyId).HasColumnName("CompanyId"); this.Property(t => t.ClientId).HasColumnName("ClientId"); // Relationships this.HasRequired(t => t.Client) .WithMany(t => t.Company2Client) .HasForeignKey(d => d.ClientId); this.HasRequired(t => t.Company) .WithMany(t => t.Company2Client) .HasForeignKey(d => d.CompanyId); } } }