Search code examples
asp.netconnectioncouchbasebucket

how to connect to bucket from asp.net using couchbase 5.1.0


I used couchbase 4.5 first. After making improvements(upgrading to couhcbase 5.1.0), the following error has occurred. Help me

the error is shown as an image

    public class ApplicationDbContext : ThrowableBucket //IdentityDbContext<ApplicationUser>
{   


    //static string _bucketName = ConfigurationManager.AppSettings["CouchbaseBucketTest"] ?? "default";
    public ApplicationDbContext()

        //: base("DefaultConnection", throwIfV1Schema: false)
        //: base(cl.OpenBucket("default","123123"))
        : base(ClusterHelper.GetBucket("default", "123123"))
    {
    }

    public static ApplicationDbContext Create()
    {

        return new ApplicationDbContext();
    }
}

Solution

  • With Couchbase 5.0, the authentication model has changed. You no longer have passwords on buckets. Instead, you have users, who are given certain permissions to a bucket. For more information, check out the Couchbase docs.

    In short, create a user. Give that user permission to the bucket. Authenticate to that user at the cluster level, and use .GetBucket("bucketname") without specifying a password.

    However, in an attempt to help introduce a smooth transition, you can use the old 4.x overloads if you create a user with the same name as the bucket. So, in this case, you're trying to use the old API, but you don't have a user named "default".