public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrEmpty(name))
            {
                name = "LiteDbRoleProvider";
            }

            base.Initialize(name, config);

            _connectionString = ConfigurationManager.ConnectionStrings[config["connectionStringName"]].ConnectionString;

            _applicationName = config["applicationName"];
            _description     = config["description"];

            config.Remove("connectionStringName");
            config.Remove("applicationName");
            config.Remove("commandTimeout");

            _rolesService = new AspnetSecurityService(new LiteDbContext(_connectionString));
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrEmpty(name))
            {
                name = "LiteDbMembershipProvider";
            }

            base.Initialize(name, config);

            _schemaVersionCheck = 0;

            _connectionString = ConfigurationManager.ConnectionStrings[config["connectionStringName"]].ConnectionString;

            _applicationName = config["applicationName"];
            _description     = config["description"];
            _passwordStrengthRegularExpression = config["passwordStrengthRegularExpression"];

            bool.TryParse(config["enablePasswordRetrieval"], out _enablePasswordRetrieval);
            bool.TryParse(config["enablePasswordReset"], out _enablePasswordReset);
            bool.TryParse(config["requiresQuestionAndAnswer"], out _requiresQuestionAndAnswer);
            bool.TryParse(config["requiresUniqueEmail"], out _requiresUniqueEmail);
            int.TryParse(config["maxInvalidPasswordAttempts"], out _maxInvalidPasswordAttempts);
            int.TryParse(config["passwordAttemptWindow"], out _passwordAttemptWindow);
            int.TryParse(config["minRequiredPasswordLength"], out _minRequiredPasswordLength);
            int.TryParse(config["minRequiredNonalphanumericCharacters"], out _minRequiredNonalphanumericCharacters);

            string passwordFormat = config["passwordFormat"];

            if (passwordFormat == null)
            {
                passwordFormat = "Hashed";
            }

            switch (passwordFormat)
            {
            case "Clear":
                _passwordFormat = MembershipPasswordFormat.Clear;
                break;

            case "Encrypted":
                _passwordFormat = MembershipPasswordFormat.Encrypted;
                break;

            case "Hashed":
                _passwordFormat = MembershipPasswordFormat.Hashed;
                break;

            default:
                _passwordFormat = MembershipPasswordFormat.Hashed;
                break;
            }

            config.Remove("connectionStringName");
            config.Remove("enablePasswordRetrieval");
            config.Remove("enablePasswordReset");
            config.Remove("requiresQuestionAndAnswer");
            config.Remove("applicationName");
            config.Remove("requiresUniqueEmail");
            config.Remove("maxInvalidPasswordAttempts");
            config.Remove("passwordAttemptWindow");
            config.Remove("commandTimeout");
            config.Remove("passwordFormat");
            config.Remove("name");
            config.Remove("minRequiredPasswordLength");
            config.Remove("minRequiredNonalphanumericCharacters");
            config.Remove("passwordStrengthRegularExpression");

            _membershipService = new AspnetSecurityService(new LiteDbContext(_connectionString));

            var oldApplicationInfo = _membershipService.GetApplication(ApplicationName);

            if (oldApplicationInfo == null)
            {
                _membershipService.Insert(new ApplicationsInfo {
                    Id = Guid.NewGuid(), Name = ApplicationName
                });
            }
        }