2015-04-15 23:57:36 +08:00
|
|
|
|
using System.Data.Entity.ModelConfiguration;
|
|
|
|
|
using OpenAuth.Domain;
|
2015-04-25 12:31:01 +08:00
|
|
|
|
using OpenAuth.Domain.Model;
|
2015-04-15 23:57:36 +08:00
|
|
|
|
|
|
|
|
|
namespace OpenAuth.Infrastructure.Mapping
|
|
|
|
|
{
|
|
|
|
|
public class RoleMap : EntityTypeConfiguration<Role>
|
|
|
|
|
{
|
|
|
|
|
public RoleMap()
|
|
|
|
|
{
|
|
|
|
|
// Primary Key
|
|
|
|
|
this.HasKey(t => t.RoleId);
|
|
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
|
this.Property(t => t.RoleId)
|
|
|
|
|
.IsRequired()
|
|
|
|
|
.HasMaxLength(50);
|
|
|
|
|
|
|
|
|
|
this.Property(t => t.ParentId)
|
|
|
|
|
.HasMaxLength(50);
|
|
|
|
|
|
|
|
|
|
this.Property(t => t.FullName)
|
|
|
|
|
.HasMaxLength(50);
|
|
|
|
|
|
|
|
|
|
this.Property(t => t.Category)
|
|
|
|
|
.HasMaxLength(50);
|
|
|
|
|
|
|
|
|
|
this.Property(t => t.Description)
|
|
|
|
|
.HasMaxLength(200);
|
|
|
|
|
|
|
|
|
|
this.Property(t => t.DepartmentId)
|
|
|
|
|
.HasMaxLength(50);
|
|
|
|
|
|
2015-04-27 17:54:50 +08:00
|
|
|
|
//<2F><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>
|
2015-04-25 12:31:01 +08:00
|
|
|
|
this.HasMany(d => d.Users)
|
|
|
|
|
.WithMany(u => u.Roles)
|
|
|
|
|
.Map(
|
|
|
|
|
m =>
|
|
|
|
|
{
|
|
|
|
|
m.MapLeftKey("RoleId");
|
|
|
|
|
m.MapRightKey("UserId");
|
|
|
|
|
m.ToTable("UserRole");
|
|
|
|
|
});
|
|
|
|
|
|
2015-04-27 17:54:50 +08:00
|
|
|
|
//<2F><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD>IJ˵<C4B2>
|
|
|
|
|
this.HasMany(m => m.RoleMenus)
|
|
|
|
|
.WithMany(r => r.Roles)
|
|
|
|
|
.Map(m =>
|
|
|
|
|
{
|
|
|
|
|
m.MapLeftKey("RoleId");
|
|
|
|
|
m.MapRightKey("MenuId");
|
|
|
|
|
m.ToTable("RoleMenu");
|
|
|
|
|
});
|
|
|
|
|
|
2015-04-15 23:57:36 +08:00
|
|
|
|
|
|
|
|
|
// Table & Column Mappings
|
|
|
|
|
this.ToTable("Role");
|
|
|
|
|
this.Property(t => t.RoleId).HasColumnName("RoleId");
|
|
|
|
|
this.Property(t => t.ParentId).HasColumnName("ParentId");
|
|
|
|
|
this.Property(t => t.FullName).HasColumnName("FullName");
|
|
|
|
|
this.Property(t => t.Category).HasColumnName("Category");
|
|
|
|
|
this.Property(t => t.Description).HasColumnName("Description");
|
|
|
|
|
this.Property(t => t.Enabled).HasColumnName("Enabled");
|
|
|
|
|
this.Property(t => t.SortCode).HasColumnName("SortCode");
|
|
|
|
|
this.Property(t => t.DeleteMark).HasColumnName("DeleteMark");
|
|
|
|
|
this.Property(t => t.DepartmentId).HasColumnName("DepartmentId");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|