/// <summary> /// Set mapping of identity role. /// </summary> /// <param name="map">Mapping. If null, the default mapping will be used.</param> protected void SetIdentiyRoleMap(IdentityRoleMap <TRole, TKey, TUserRole> map) { if (map != null) { _roleMap = map; } else { _roleMap = new IdentityRoleMap <TRole, TKey, TUserRole>( new RoleConfiguration <TRole, TKey, TUserRole>()); } }
/// <summary> /// This method is called when the model for a derived context has been initialized, /// but before the model has been locked down and used to initialize the context. /// The default implementation of this method does default initialization for default /// ASP.NET identity entities, but it can be overridden in a derived class such that /// the model can be further configured before it is locked down. /// NOTE: If only default ASP.NET identity entities need to be customeized, instead of /// overriding this method, override <see cref="SetIdentityEntityMappings()"/> method. /// </summary> /// <param name="modelBuilder">The builder that defines the model for the context being created.</param> protected override void OnModelCreating(DbModelBuilder modelBuilder) { if (modelBuilder == null) { throw new ArgumentNullException("'modelBuilder' parameter null"); } SetIdentityEntityMappings(); modelBuilder.Configurations.Add(_userMap); modelBuilder.Configurations.Add(_roleMap); modelBuilder.Configurations.Add(_userLoginMap); modelBuilder.Configurations.Add(_userRoleMap); modelBuilder.Configurations.Add(_userClaimMap); // Mapping set. Not needed now. _userMap = null; _roleMap = null; _userLoginMap = null; _userRoleMap = null; _userClaimMap = null; }