EnVisageOnline/Main-RMO/Source/IntegrationTests/Models/Mapping/ClientMap.cs

36 lines
1.0 KiB
C#

using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
namespace IntegrationTests.Models.Mapping
{
public class ClientMap : EntityTypeConfiguration<Client>
{
public ClientMap()
{
// Primary Key
this.HasKey(t => t.Id);
// Properties
this.Property(t => t.Name)
.IsRequired()
.HasMaxLength(200);
this.Property(t => t.ClientNumber)
.HasMaxLength(100);
// Table & Column Mappings
this.ToTable("Client");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Name).HasColumnName("Name");
this.Property(t => t.ClientNumber).HasColumnName("ClientNumber");
this.Property(t => t.GLAccountId).HasColumnName("GLAccountId");
// Relationships
this.HasOptional(t => t.GLAccount)
.WithMany(t => t.Clients)
.HasForeignKey(d => d.GLAccountId);
}
}
}