35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Data.Entity.ModelConfiguration;
|
|
|
|
namespace IntegrationTests.Models.Mapping
|
|
{
|
|
public class VacationMap : EntityTypeConfiguration<Vacation>
|
|
{
|
|
public VacationMap()
|
|
{
|
|
// Primary Key
|
|
this.HasKey(t => t.Id);
|
|
|
|
// Properties
|
|
this.Property(t => t.Weekends)
|
|
.IsRequired()
|
|
.HasMaxLength(256);
|
|
|
|
// Table & Column Mappings
|
|
this.ToTable("Vacation");
|
|
this.Property(t => t.Id).HasColumnName("Id");
|
|
this.Property(t => t.StartDate).HasColumnName("StartDate");
|
|
this.Property(t => t.EndDate).HasColumnName("EndDate");
|
|
this.Property(t => t.PeopleResourceId).HasColumnName("PeopleResourceId");
|
|
this.Property(t => t.HoursOff).HasColumnName("HoursOff");
|
|
this.Property(t => t.Weekends).HasColumnName("Weekends");
|
|
|
|
// Relationships
|
|
this.HasRequired(t => t.PeopleResource)
|
|
.WithMany(t => t.Vacations)
|
|
.HasForeignKey(d => d.PeopleResourceId);
|
|
|
|
}
|
|
}
|
|
}
|