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

79 lines
3.0 KiB
C#

using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
namespace IntegrationTests.Models.Mapping
{
public class UserMap : EntityTypeConfiguration<User>
{
public UserMap()
{
// Primary Key
this.HasKey(t => new { t.Id, t.Type, t.UserName, t.Password, t.FirstName, t.LastName, t.EmailAddress, t.LastLoginDate, t.CreateDate, t.CreatedBy, t.LastUpdateDate, t.UserStatus });
// Properties
this.Property(t => t.Type)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
this.Property(t => t.UserName)
.IsRequired()
.HasMaxLength(32);
this.Property(t => t.Password)
.IsRequired()
.HasMaxLength(32);
this.Property(t => t.FirstName)
.IsRequired()
.HasMaxLength(20);
this.Property(t => t.LastName)
.IsRequired()
.HasMaxLength(30);
this.Property(t => t.MiddleInit)
.IsFixedLength()
.HasMaxLength(1);
this.Property(t => t.EmailAddress)
.IsRequired()
.HasMaxLength(256);
this.Property(t => t.Phone)
.HasMaxLength(20);
this.Property(t => t.Fax)
.HasMaxLength(20);
this.Property(t => t.MobilePhone)
.HasMaxLength(20);
this.Property(t => t.CreatedBy)
.IsRequired()
.HasMaxLength(32);
this.Property(t => t.UserStatus)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
// Table & Column Mappings
this.ToTable("User");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Type).HasColumnName("Type");
this.Property(t => t.UserName).HasColumnName("UserName");
this.Property(t => t.Password).HasColumnName("Password");
this.Property(t => t.FirstName).HasColumnName("FirstName");
this.Property(t => t.LastName).HasColumnName("LastName");
this.Property(t => t.MiddleInit).HasColumnName("MiddleInit");
this.Property(t => t.EmailAddress).HasColumnName("EmailAddress");
this.Property(t => t.Phone).HasColumnName("Phone");
this.Property(t => t.Fax).HasColumnName("Fax");
this.Property(t => t.MobilePhone).HasColumnName("MobilePhone");
this.Property(t => t.LastLoginDate).HasColumnName("LastLoginDate");
this.Property(t => t.CreateDate).HasColumnName("CreateDate");
this.Property(t => t.CreatedBy).HasColumnName("CreatedBy");
this.Property(t => t.LastUpdateDate).HasColumnName("LastUpdateDate");
this.Property(t => t.UserStatus).HasColumnName("UserStatus");
this.Property(t => t.ModifiedBy).HasColumnName("ModifiedBy");
}
}
}