EnVisageOnline/Beta/Source/IntegrationTests/Models/Mapping/ContactMap.cs

47 lines
1.5 KiB
C#

using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
namespace IntegrationTests.Models.Mapping
{
public class ContactMap : EntityTypeConfiguration<Contact>
{
public ContactMap()
{
// Primary Key
this.HasKey(t => t.Id);
// Properties
this.Property(t => t.LastName)
.IsRequired()
.HasMaxLength(100);
this.Property(t => t.FirstName)
.IsRequired()
.HasMaxLength(100);
this.Property(t => t.MiddleInt)
.IsFixedLength()
.HasMaxLength(1);
this.Property(t => t.Email)
.IsRequired()
.HasMaxLength(100);
this.Property(t => t.Phone)
.HasMaxLength(100);
// Table & Column Mappings
this.ToTable("Contact");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Type).HasColumnName("Type");
this.Property(t => t.LastName).HasColumnName("LastName");
this.Property(t => t.FirstName).HasColumnName("FirstName");
this.Property(t => t.MiddleInt).HasColumnName("MiddleInt");
this.Property(t => t.Email).HasColumnName("Email");
this.Property(t => t.Phone).HasColumnName("Phone");
this.Property(t => t.ParentId).HasColumnName("ParentId");
this.Property(t => t.ContactClassification).HasColumnName("ContactClassification");
}
}
}