Skip to main content
net8.0

ADO.NET Data Provider. Alpha version: Not for production use

Published
Feb 25, 2026
7mo ago
Total Downloads
369
369

Install

dotnet add package Google.Cloud.Spanner.DataProvider --version 1.0.0-alpha.20260123102444
ProductVersions
.NET
net8.0

README

Spanner ADO.NET Data Provider

ALPHA: This library is still in development. It is not yet ready for production use.

ADO.NET Data Provider for Spanner. This library implements the standard ADO.NET interfaces and classes and exposes an API that is similar to ADO.NET data providers for other relational database systems.

Supported Platforms

This driver uses a native library for communication with Spanner. This library supports the following operating systems and architectures:

  • linux-x64
  • linux-arm64
  • osx-arm64
  • win-x64

Usage

Create a connection string using a SpannerConnectionStringBuilder:

var builder = new SpannerConnectionStringBuilder
{
    Project = "my-project",
    Instance = "my-instance",
    Database = "my-database",
    DefaultIsolationLevel = IsolationLevel.ReadCommitted,
};
await using var connection = new SpannerConnection(builder.ConnectionString);
await connection.OpenAsync();
await using var command = connection.CreateCommand();
command.CommandText = "SELECT 'Hello World' as Message";
await using var reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
    Console.WriteLine($"Greeting from Spanner: {reader.GetString(0)}");
}

Emulator

The driver can also connect to the Spanner Emulator. The easiest way to do this is to set the AutoConfigEmulator property to true. This instructs the driver to connect to the Emulator on localhost:9010 and to automatically create the Spanner instance and database in the connection string if these do not already exist.

var builder = new SpannerConnectionStringBuilder
{
    Project = "my-project",
    Instance = "my-instance",
    Database = "my-database",
    DefaultIsolationLevel = IsolationLevel.ReadCommitted,
    // Setting AutoConfigEmulator=true instructs the driver to connect to the Spanner emulator on 'localhost:9010',
    // and to create the instance and database on the emulator if these do not already exist.
    AutoConfigEmulator = true,
};
await using var connection = new SpannerConnection(builder.ConnectionString);
await connection.OpenAsync();
await using var command = connection.CreateCommand();
command.CommandText = "SELECT 'Hello World' as Message";
await using var reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
    Console.WriteLine($"Greeting from Spanner: {reader.GetString(0)}");
}

Examples

See the spanner-ado-net-samples project for ready-to-run examples for how to use various Spanner features with this driver.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.