44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Data.Entity.ModelConfiguration;
|
|
|
|
namespace IntegrationTests.Models.Mapping
|
|
{
|
|
public class TeamMap : EntityTypeConfiguration<Team>
|
|
{
|
|
public TeamMap()
|
|
{
|
|
// Primary Key
|
|
this.HasKey(t => t.Id);
|
|
|
|
// Properties
|
|
this.Property(t => t.Name)
|
|
.IsRequired()
|
|
.HasMaxLength(100);
|
|
|
|
// Table & Column Mappings
|
|
this.ToTable("Team");
|
|
this.Property(t => t.Id).HasColumnName("Id");
|
|
this.Property(t => t.Name).HasColumnName("Name");
|
|
this.Property(t => t.CompanyId).HasColumnName("CompanyId");
|
|
this.Property(t => t.CostCenterId).HasColumnName("CostCenterId");
|
|
this.Property(t => t.ReportsTo).HasColumnName("ReportsTo");
|
|
this.Property(t => t.PlannedCapacityScenarioId).HasColumnName("PlannedCapacityScenarioId");
|
|
|
|
// Relationships
|
|
this.HasOptional(t => t.Company)
|
|
.WithMany(t => t.Teams)
|
|
.HasForeignKey(d => d.CompanyId);
|
|
this.HasOptional(t => t.Contact)
|
|
.WithMany(t => t.Teams)
|
|
.HasForeignKey(d => d.ReportsTo);
|
|
this.HasOptional(t => t.CreditDepartment)
|
|
.WithMany(t => t.Teams)
|
|
.HasForeignKey(d => d.CostCenterId);
|
|
this.HasOptional(t => t.Scenario)
|
|
.WithMany(t => t.Teams)
|
|
.HasForeignKey(d => d.PlannedCapacityScenarioId);
|
|
|
|
}
|
|
}
|
|
}
|