Getting started

Getting started

This section shows how to add the Couchbase .NET SDK to your application and how to get up and running with the client by way of a simple “Hello Couchbase” application.

Installing the Client

You can add the Couchbase .NET SDK to your code by using one of the following methods:

  • Using NuGet (recommended method)
  • Downloading and referencing the binaries
  • Building from source yourself

The following sections explain in detail how to get started using each method.

Using NuGet

For every release, we package the binaries and store the latest version in NuGet . If you are not familiar with NuGet, it’s the official and most widely supported package manager for Microsoft Visual Studio and .NET in general. NuGet is a centralized repository for package authors and consumers, and it also defines a suite of tools for authoring and consuming packages.

Using Visual Studio 2012 or later, follow these steps to get started with the Couchbase .NET SDK:

  1. From the IDE, right-click the project you want to add the dependency to.
  2. In the context menu, click Manage NuGet Packages . The NuGet package manager modal dialog opens.
  3. From the Tree View menu on the left, select Online > nuget.org .
  4. In the search box at the top right-hand side of the dialog, type CouchbaseNetClient and then press enter on your keyboard.
  5. In the search results, select the CouchbaseNetClient package and then click Install .

That’s it! NuGet will pull in all required dependencies and reference them. You're ready to start coding!

As an alternative to using the Visual Studio IDE, you can include the binaries by using the Package Manager Console. The main advantage of using the Package Manager Console is that the NuGet Dialog by default always installs the latest version of the package published to NuGet.org, however the console allows you to define the version of the package you want to include. For users targeting older builds of the SDK, using the Package Manager Console is the best option.

To use the Package Manager Console to include the SDK in your project:

  1. From the Visual Studio menu bar, click Tools .
  2. Select NuGet Package Manager > Package Manager Console .
  3. In the console, enter the package installation command:
    • To install the latest version:
      Install-Package CouchbaseNetClient
    • To install a specific version, include the version parameter. For example:
      Install-Package CouchbaseNetClient -Version 2.0.0-beta -Pre

Downloading and referencing the binaries

If you do not want to use NuGet to include the Couchbase .NET SDK in your project, you can download and reference the binaries directly. If you chose this route, you’ll also be responsible for including and resolving dependencies used internally by the SDK.

To download and reference the binaries directly:

  1. Download the version of the SDK you want to install.
  2. In Visual Studio, right-click the project you want to include the SDK in and then click Add .
  3. Click Reference to open the Reference Manager.
  4. On the left side, click Browse and select the binaries you downloaded.
  5. Click OK .

After you have referenced the Couchbase .NET SDK binaries, you need to locate and reference the dependencies it uses in a similar fashion. At the time of this writing, the dependencies are:

Other versions might not be compatible with the current SDK version.

Building from source

If none of the other installation options suffice or if you want to debug the source or perhaps contribute, building directly from the source is the best option for you. All source is located on GitHub.

Note:

The software provided via NuGet and S3 are the official releases that have been through a rigorous testing process. Code on GitHub that is not tagged as an official release is still in development.

To build the .NET SDK from source:

  1. ( Optional ) Fork the GitHub repository: https://github.com/couchbase/couchbase-net-client/fork
  2. Using a Git console, enter the command to clone the repository:
    git clone https://github.com/couchbase/couchbase-net-client.git
  3. Enter the command to retrieve the latest code from GitHub:
    git pull origin master
  4. Navigate to the directory that the source was cloned to and open the solution.
  5. Build the solution.

After you have successfully built the source, it’s then just a matter of referencing the binaries (.DLL files) from your consuming project.