Migrate C# driver

Complete the following procedure to migrate your existing DataStax C# driver to a version that is capable of connecting to Astra databases created using DataStax Astra DB.

Prerequisites

Procedure

  1. Add the dependencies for the C# driver to your project.

    • DataStax C# driver for Apache Cassandra

    • DSE C# driver

    dotnet add package CassandraCSharpDriver -v 3.15.0
    dotnet add package Dse -v 3.15.0
  2. In your existing DataStax C# driver code, modify the connection code to use the Astra DB API.

    Include the absolute path to the secure connect bundle for your Cassandra database (secure-connect-database_name.zip) in the WithCloudSecureConnectionBundle method call, and your credentials in the WithCredentials method call, as shown in the following examples.

    • DataStax C# driver for Apache Cassandra

    • DSE C# driver

    var session =
      Cluster.Builder()
          .WithCloudSecureConnectionBundle(@"C:\path\to\secure-connect-database_name.zip")
            .WithCredentials("clientId", "clientSecret")
            .Build()
            .Connect();
    var session =
      DseCluster.Builder()
          .WithCloudSecureConnectionBundle(@"C:\path\to\secure-connect-database_name.zip")
            .WithCredentials("clientId", "clientSecret")
            .Build()
            .Connect();
  3. Run your application.