using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfiguration; namespace IntegrationTests.Models.Mapping { public class User2ViewMap : EntityTypeConfiguration { public User2ViewMap() { // Primary Key this.HasKey(t => t.Id); // Properties // Table & Column Mappings this.ToTable("User2View"); this.Property(t => t.Id).HasColumnName("Id"); this.Property(t => t.UserId).HasColumnName("UserId"); this.Property(t => t.ViewId).HasColumnName("ViewId"); // Relationships this.HasOptional(t => t.View) .WithMany(t => t.User2View) .HasForeignKey(d => d.ViewId); } } }