59 lines
2.1 KiB
C#
59 lines
2.1 KiB
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Data.Entity.ModelConfiguration;
|
|
|
|
namespace IntegrationTests.Models.Mapping
|
|
{
|
|
public class ProjectMap : EntityTypeConfiguration<Project>
|
|
{
|
|
public ProjectMap()
|
|
{
|
|
// Primary Key
|
|
this.HasKey(t => t.Id);
|
|
|
|
// Properties
|
|
this.Property(t => t.Name)
|
|
.IsRequired()
|
|
.HasMaxLength(200);
|
|
|
|
this.Property(t => t.ProjectNumber)
|
|
.HasMaxLength(50);
|
|
|
|
this.Property(t => t.Color)
|
|
.HasMaxLength(16);
|
|
|
|
this.Property(t => t.Details)
|
|
.HasMaxLength(4000);
|
|
|
|
// Table & Column Mappings
|
|
this.ToTable("Project");
|
|
this.Property(t => t.Id).HasColumnName("Id");
|
|
this.Property(t => t.CompanyId).HasColumnName("CompanyId");
|
|
this.Property(t => t.ClientId).HasColumnName("ClientId");
|
|
this.Property(t => t.TypeId).HasColumnName("TypeId");
|
|
this.Property(t => t.StatusId).HasColumnName("StatusId");
|
|
this.Property(t => t.Name).HasColumnName("Name");
|
|
this.Property(t => t.ProjectNumber).HasColumnName("ProjectNumber");
|
|
this.Property(t => t.Color).HasColumnName("Color");
|
|
this.Property(t => t.Details).HasColumnName("Details");
|
|
this.Property(t => t.Priority).HasColumnName("Priority");
|
|
this.Property(t => t.Probability).HasColumnName("Probability");
|
|
this.Property(t => t.IsRevenueGenerating).HasColumnName("IsRevenueGenerating");
|
|
|
|
// Relationships
|
|
this.HasOptional(t => t.Client)
|
|
.WithMany(t => t.Projects)
|
|
.HasForeignKey(d => d.ClientId);
|
|
this.HasOptional(t => t.Company)
|
|
.WithMany(t => t.Projects)
|
|
.HasForeignKey(d => d.CompanyId);
|
|
this.HasRequired(t => t.Status)
|
|
.WithMany(t => t.Projects)
|
|
.HasForeignKey(d => d.StatusId);
|
|
this.HasRequired(t => t.Type)
|
|
.WithMany(t => t.Projects)
|
|
.HasForeignKey(d => d.TypeId);
|
|
|
|
}
|
|
}
|
|
}
|