using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfiguration; namespace IntegrationTests.Models.Mapping { public class NonProjectTimeMap : EntityTypeConfiguration { public NonProjectTimeMap() { // Primary Key this.HasKey(t => t.Id); // Properties this.Property(t => t.Name) .IsRequired() .HasMaxLength(255); this.Property(t => t.Weekends) .IsRequired() .HasMaxLength(256); // Table & Column Mappings this.ToTable("NonProjectTime"); this.Property(t => t.Id).HasColumnName("Id"); this.Property(t => t.Name).HasColumnName("Name"); this.Property(t => t.StartDate).HasColumnName("StartDate"); this.Property(t => t.EndDate).HasColumnName("EndDate"); this.Property(t => t.NonProjectTimeCategoryId).HasColumnName("NonProjectTimeCategoryId"); this.Property(t => t.Cost).HasColumnName("Cost"); this.Property(t => t.PercentAllocated).HasColumnName("PercentAllocated"); this.Property(t => t.Weekends).HasColumnName("Weekends"); // Relationships this.HasRequired(t => t.NonProjectTimeCategory) .WithMany(t => t.NonProjectTimes) .HasForeignKey(d => d.NonProjectTimeCategoryId); } } }