title: How to get the bucket when previously specified with `Cluster.ConnectAsync`
body: <p>I initiated the Cluster in DI with the following code:</p>
  <pre class="lang-cs prettyprint-override"><code>serviceCollection.AddSingleton&lt;ICouchbaseRepository&gt;(service =&gt;
  {
      var couchbaseOptions = service.GetService&lt;AppSettings&gt;()?.CouchbaseOptions
                              ?? throw new NullReferenceException(nameof(CouchbaseOptions));
      var cluster = Cluster.ConnectAsync(new ClusterOptions
      {
          ConnectionString = couchbaseOptions.ConnectionString,
          Buckets = new List&lt;string&gt; { couchbaseOptions.Bucket }, // See here
          UserName = couchbaseOptions.Username,
          Password = couchbaseOptions.Password
      });
      return new CouchbaseRepository(cluster);
  });
  </code></pre>
  <p>As I specified the bucket name in the initialisation process, how can I access it later without providing the bucket name?</p>
  <p>I cannot use something like Cluster.BucketAsync() as it requires the bucket name here (what’s the point of having to specify the name again when I have specified the desired bucket name previously?).</p>
  <p>I tried with <code>Cluster.Buckets.GetAllBucketsAsync()</code> but I got the <code>ArgumentNullException</code>; using <code>Cluster.Buckets.GetAllBucketsAsync(new GetAllBucketsOptions())</code> or <code>Cluster.Buckets.GetAllBucketsAsync(GetAllBucketsOptions.Default)</code> don’t work either (same errors).</p>
  <pre><code>Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'value')
     at Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull(Object value, String parameterName)
  
     at Newtonsoft.Json.Linq.Extensions.Value[T,U](IEnumerable`1 value)
     at Newtonsoft.Json.Linq.Extensions.Value[U](IEnumerable`1 value)
     at Couchbase.Management.Buckets.BucketManager.GetBucketSettings(JToken json)
     at Couchbase.Management.Buckets.BucketManager.GetAllBucketsAsync(GetAllBucketsOptions options)
  </code></pre>
  <p>Environment:</p>
  <ul>
  <li>.NET Core 5</li>
  <li>CouchbaseNetClient 3.1.3</li>
  <li>Couchbase Server community-6.6.0</li>
  <li>Runs on Docker</li>
  </ul>
  <p>Note: this is a cross-post from Couchbase's forum: <a href="https://forums.couchbase.com/t/how-to-get-the-bucket-when-previously-specified-with-cluster-connectasync/29877" rel="nofollow noreferrer">https://forums.couchbase.com/t/how-to-get-the-bucket-when-previously-specified-with-cluster-connectasync/29877</a></p>