Connecting to couchbase in an ASP.NET Core console application

I am trying to connect to Couchbase using JSON configuration in an ASP.NET Core console application. The documentation looks like this:

var jsonConfiguration = builder.Build();
var clientConfig = new ClientConfiguration(jsonConfiguration.Get(name));

However, I can’t figure out where the Get extension method lives. I get a compile time error that says IConfigurationManager doesn’t contain a method called Get. Maybe I’m missing something completely obvious, but I can’t find it for the life of me.

@mmiller

I believe it lives in https://www.nuget.org/packages/microsoft.extensions.configuration.binder/ Microsoft.Extensions.Configuration.Binder.

However, I think the syntax may have changed slightly since the prerelease version of the package. Try this (substitute the string for the path to the config in your JSON file):

var definition = new CouchbaseClientDefinition();
jsonConfiguration.GetSection("couchbase:couchbaseClient").Bind(definition);

Brant

That seems to have done the trick, @btburnett3. Thank you so much.

Thanks @btburnett3

@mmiller - I created a ticket for tracking. The docs should be updated shortly.

-Jeff

1 Like