using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfiguration; namespace IntegrationTests.Models.Mapping { public class AspNetRoleMap : EntityTypeConfiguration { public AspNetRoleMap() { // Primary Key this.HasKey(t => t.Id); // Properties this.Property(t => t.Id) .IsRequired() .HasMaxLength(128); this.Property(t => t.Name) .HasMaxLength(4000); // Table & Column Mappings this.ToTable("AspNetRoles"); this.Property(t => t.Id).HasColumnName("Id"); this.Property(t => t.Name).HasColumnName("Name"); // Relationships this.HasMany(t => t.AspNetUsers) .WithMany(t => t.AspNetRoles) .Map(m => { m.ToTable("AspNetUserRoles"); m.MapLeftKey("RoleId"); m.MapRightKey("UserId"); }); } } }