Пример #1
0
 /// <summary>
 /// Set mapping of identity user.
 /// </summary>
 /// <param name="map">Mapping. If null, the default mapping will be used.</param>
 protected void SetIdentiyUserMap(IdentityUserMap <TUser, TKey, TUserLogin, TUserRole, TUserClaim> map)
 {
     if (map != null)
     {
         _userMap = map;
     }
     else
     {
         _userMap = new IdentityUserMap <TUser, TKey, TUserLogin, TUserRole, TUserClaim>(
             new UserConfiguration <TUser, TKey, TUserLogin, TUserRole, TUserClaim>());
     }
 }
Пример #2
0
        /// <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;
        }