41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Data.Entity.ModelConfiguration;
|
|
|
|
namespace IntegrationTests.Models.Mapping
|
|
{
|
|
public class TrainingMap : EntityTypeConfiguration<Training>
|
|
{
|
|
public TrainingMap()
|
|
{
|
|
// 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("Training");
|
|
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.TrainingTypeId).HasColumnName("TrainingTypeId");
|
|
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.TrainingType)
|
|
.WithMany(t => t.Trainings)
|
|
.HasForeignKey(d => d.TrainingTypeId);
|
|
|
|
}
|
|
}
|
|
}
|