using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfiguration; namespace IntegrationTests.Models.Mapping { public class ClientMap : EntityTypeConfiguration { public ClientMap() { // Primary Key this.HasKey(t => t.Id); // Properties this.Property(t => t.Name) .IsRequired() .HasMaxLength(200); this.Property(t => t.ClientNumber) .HasMaxLength(100); // Table & Column Mappings this.ToTable("Client"); this.Property(t => t.Id).HasColumnName("Id"); this.Property(t => t.Name).HasColumnName("Name"); this.Property(t => t.ClientNumber).HasColumnName("ClientNumber"); this.Property(t => t.GLAccountId).HasColumnName("GLAccountId"); // Relationships this.HasOptional(t => t.GLAccount) .WithMany(t => t.Clients) .HasForeignKey(d => d.GLAccountId); } } }