using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfiguration; namespace IntegrationTests.Models.Mapping { public class Expenditure2ExpenditureMap : EntityTypeConfiguration { public Expenditure2ExpenditureMap() { // Primary Key this.HasKey(t => t.Id); // Properties // Table & Column Mappings this.ToTable("Expenditure2Expenditure"); this.Property(t => t.Id).HasColumnName("Id"); this.Property(t => t.ParentId).HasColumnName("ParentId"); this.Property(t => t.ChildId).HasColumnName("ChildId"); this.Property(t => t.FactorType).HasColumnName("FactorType"); this.Property(t => t.ProcessOrder).HasColumnName("ProcessOrder"); this.Property(t => t.FactorInt).HasColumnName("FactorInt"); // Relationships this.HasRequired(t => t.ExpenditureCategory) .WithMany(t => t.Expenditure2Expenditure) .HasForeignKey(d => d.ChildId); this.HasRequired(t => t.ExpenditureCategory1) .WithMany(t => t.Expenditure2Expenditure1) .HasForeignKey(d => d.ParentId); } } }