public void Initialize(EFRoleProvider <TRole, TUserRole, TRoleKey> Provider) { this.Provider = Provider; //Role Table var roleType = typeof(TRole); var tblNameAttr = roleType.GetCustomAttributes(typeof(TableAttribute), true); var noPrefixAttr = roleType.GetCustomAttributes(typeof(NoPrefixAttribute), true); RoleTableNoPrefix = noPrefixAttr != null && noPrefixAttr.Length > 0; var first = tblNameAttr.FirstOrDefault() as TableAttribute; if (first != null) { RoleTableName = first; } else { RoleTableName = new TableAttribute(roleType.Name.Trim().Replace(" ", "")); } if (!RoleTableNoPrefix && !string.IsNullOrWhiteSpace(Provider.TablePrefix)) { var schema = RoleTableName.Schema; RoleTableName = new TableAttribute(Provider.TablePrefix + RoleTableName.Name); if (schema != null) { RoleTableName.Schema = schema; } } RoleType = roleType; //User Role Table var userRoleType = typeof(TUserRole); tblNameAttr = userRoleType.GetCustomAttributes(typeof(TableAttribute), true); noPrefixAttr = userRoleType.GetCustomAttributes(typeof(NoPrefixAttribute), true); UserRoleTableNoPrefix = noPrefixAttr != null && noPrefixAttr.Length > 0; first = tblNameAttr.FirstOrDefault() as TableAttribute; if (first != null) { UserRoleTableName = first; } else { UserRoleTableName = new TableAttribute(userRoleType.Name.Trim().Replace(" ", "")); } if (!UserRoleTableNoPrefix && !string.IsNullOrWhiteSpace(Provider.TablePrefix)) { var schema = UserRoleTableName.Schema; UserRoleTableName = new TableAttribute(Provider.TablePrefix + UserRoleTableName.Name); if (schema != null) { UserRoleTableName.Schema = schema; } } UserRoleType = userRoleType; if (Provider.SupportApplication) { //Check application table var propAppType = RoleHelper.Get(Mapper.RoleColumnType.Application); var appType = propAppType.PropertyType; tblNameAttr = appType.GetCustomAttributes(typeof(TableAttribute), true); noPrefixAttr = appType.GetCustomAttributes(typeof(NoPrefixAttribute), true); ApplicationTableNoPrefix = noPrefixAttr != null && noPrefixAttr.Length > 0; first = tblNameAttr.FirstOrDefault() as TableAttribute; if (first != null) { ApplicationTableName = first; } else { ApplicationTableName = new TableAttribute(appType.Name.Trim().Replace(" ", "")); } if (!ApplicationTableNoPrefix && !string.IsNullOrWhiteSpace(Provider.TablePrefix)) { var schema = ApplicationTableName.Schema; ApplicationTableName = new TableAttribute(Provider.TablePrefix + ApplicationTableName.Name); if (schema != null) { ApplicationTableName.Schema = schema; } } ApplicationType = appType; } }