using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfiguration; namespace IntegrationTests.Models.Mapping { public class ProjectAccessMap : EntityTypeConfiguration { public ProjectAccessMap() { // Primary Key this.HasKey(t => new { t.PrincipalId, t.ProjectId }); // Properties // Table & Column Mappings this.ToTable("ProjectAccess"); this.Property(t => t.PrincipalId).HasColumnName("PrincipalId"); this.Property(t => t.ProjectId).HasColumnName("ProjectId"); this.Property(t => t.Read).HasColumnName("Read"); this.Property(t => t.Write).HasColumnName("Write"); // Relationships this.HasRequired(t => t.Project) .WithMany(t => t.ProjectAccesses) .HasForeignKey(d => d.ProjectId); } } }