Exemple #1
0
 public static void ConfigRole <TUser, TRole, TKey>(
     this EntityTypeBuilder <TRole> builder)
     where TKey : struct, IEquatable <TKey>
     where TUser : class, IEntity <TKey>
     where TRole : ApplicationRole <TKey, TUser, TRole>
 {
     builder.ConfigForIDomainTreeEntity <TKey, TRole>();
     builder.ConfigForIOptimisticConcurrencySupported();
     builder.ConfigForICreatorRecordable <TRole, TUser, TKey>();
     builder.ConfigForILastModifierRecordable <TRole, TUser, TKey>();
     // Each Role can have many entries in the UserRole join table
     builder.HasMany(e => e.UserRoles)
     .WithOne(e => e.Role)
     .HasForeignKey(ur => ur.RoleId)
     .IsRequired();
     // Each Role can have many associated RoleClaims
     builder.HasMany(e => e.RoleClaims)
     .WithOne(e => e.Role)
     .HasForeignKey(rc => rc.RoleId)
     .IsRequired();
     builder.ToTable("AppRoles");
 }