40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Data.Entity.ModelConfiguration;
|
|
|
|
namespace IntegrationTests.Models.Mapping
|
|
{
|
|
public class AspNetRoleMap : EntityTypeConfiguration<AspNetRole>
|
|
{
|
|
public AspNetRoleMap()
|
|
{
|
|
// Primary Key
|
|
this.HasKey(t => t.Id);
|
|
|
|
// Properties
|
|
this.Property(t => t.Id)
|
|
.IsRequired()
|
|
.HasMaxLength(128);
|
|
|
|
this.Property(t => t.Name)
|
|
.HasMaxLength(4000);
|
|
|
|
// Table & Column Mappings
|
|
this.ToTable("AspNetRoles");
|
|
this.Property(t => t.Id).HasColumnName("Id");
|
|
this.Property(t => t.Name).HasColumnName("Name");
|
|
|
|
// Relationships
|
|
this.HasMany(t => t.AspNetUsers)
|
|
.WithMany(t => t.AspNetRoles)
|
|
.Map(m =>
|
|
{
|
|
m.ToTable("AspNetUserRoles");
|
|
m.MapLeftKey("RoleId");
|
|
m.MapRightKey("UserId");
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
}
|