/// <summary>
        /// Creates a new mongo user store.
        /// </summary>
        /// <param name="config">The configuration</param>
        /// <param name="disableIndexes">Indicates if indexes should be created (cosmos)</param>
        public MongoUserStore(MongoRepositoryConfig config, bool disableIndexes)
        {
            Condition.Requires(config, "config").IsNotNull();

            _usersRepository        = new MongoRepository <TUser>(config);
            _usersRepositoryManager = new MongoRepositoryManager <TUser>(config);

            if (!_disableIndexes)
            {
                EnsureIndicesCreatedAsync().GetAwaiter().GetResult();
            }
        }
        public MongoDBContextBase(IOptions <MongoDBConfiguration> settings)
        {
            if (settings.Value == null)
            {
                throw new ArgumentNullException(nameof(settings), "MongoDBConfiguration cannot be null.");
            }

            if (settings.Value.ConnectionString == null)
            {
                throw new ArgumentNullException(nameof(settings), "MongoDBConfiguration.ConnectionString cannot be null.");
            }

            if (settings.Value.Database == null)
            {
                throw new ArgumentNullException(nameof(settings), "MongoDBConfiguration.Database cannot be null.");
            }

            _client   = new MongoClient(settings.Value.ConnectionString);
            _config   = new MongoRepositoryConfig(settings.Value.ConnectionString);
            _database = _client.GetDatabase(settings.Value.Database);
        }
 /// <summary>
 /// Creates a new mongo user store.
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 public MongoUserStore(MongoRepositoryConfig config) : this(config, false)
 {
 }