Google.Cloud.Spanner.Data version 2.0 includes a number of breaking
changes compared with version 1.0. We expect that most users will
not be affected by these changes, particularly when default settings
are used. For users who are affected, this document should help you
to migrate your application to the 2.0 version of the libraries.
If you have any problems with the breaking changes and they're not
covered in this document, please file an
issue
so we can help you further.
Configuration changes
SpannerOptions has been removed completely. See the configuration
guide for more details, but for migration
purposes:
KeepAliveInterval is replaced by SessionPoolOptions.IdleSessionRefreshDelay
MaximumPooledSessions has no direct equivalent in 2.0; once a session
is part of the pool, it will be refreshed as necessary until it is evicted.
MaximumActiveSessions is now only present in SessionPoolOptions
MaximumGrpcChannels is specified in the connection string
LogLevel is controlled on a per-logger basis; this property on
SpannerOptions was equivalent to changing
Logger.DefaultLogger.LogLevel.
PoolEvictionDelay is now only present in SessionPoolOptions
ResourcesExhaustedBehavior has moved to SessionPoolOptions
Timeout is specified in the connection string
MaximumConcurrentSessionCreates is now only present in
SessionPoolOptions
ClientPool has been removed in 2.0. Its functionality has largely
been replaced by SessionPoolManager. It is expected that the
default session pool manager will be appropriate for most use cases,
but you can associate a SessionPoolManager with the
SpannerConnectionStringBuilder used to build a connection for more
advanced situations.
ResourcesExhaustedBehavior has moved to Google.Cloud.Spanner.V1,
as it is now configured in SessionPoolOptions.
Loggers are configured on a SessionPoolManager basis
Breaking changes in connection, command and transaction types
The SpannerCommandTextBuilder(string) constructor has been removed.
The equivalent functionality is available via the static
SpannerCommandTextBuilder.FromCommandText method.
SpannerTransaction.CommitAsync returns a Task<DateTime> rather
than a Task<DateTime?>. The server will always return a commit
timestamp, so the task's result would never have been null in 1.0
anyway. Client code should be able to use the resulting
Task<DateTime> more easily in most cases.
SpannerConnection and SpannerConnectionStringBuilder no longer
expose GetCredentials method. There is no direct equivalent in 2.0;
please file an issue if you rely on this functionality.
SpannerConnection.ClearPooledResourcesAsync is replaced by
SpannerConnection.ShutdownSessionPoolAsync. After this is called,
no further sessions can be created with the associated session pool.
If you need to control sessions in a more fine-grained way (for
example, shutting down one session pool but then creating new
sessions) you can associate a new SessionPoolManager instance with the
SpannerConnectionStringBuilder used to build a connection. See
the configuration guide for an example of this.
SpannerTransaction.CommitAsync now accepts a cancellation token.
This defaults to CancellationToken.None, so existing source code
should still compile, but this is a binary-incompatible change.
Miscellaneous breaking changes
SpannerDbType.StructOf has been replaced by
SpannerDbType.ForStruct, using the new SpannerStruct type.
.NET Standard 1.5 is no longer supported; only .NET 4.5 and .NET Standard 2.0
are supported targets.
Breaking changes in Google.Cloud.Spanner.V1
Users of the ADO.NET implementation in Google.Cloud.Spanner.Data
will rarely need to directly refer to the types in
Google.Cloud.Spanner.V1, but some low-level users may wish to do so.
The previous Google.Cloud.Spanner.V1.SessionPool class has been
replaced by a completely new implementation, with a new API and some
changes to the corresponding SessionPoolOptions class. The new
SessionPool manages transactions as well as sessions, so the
TransactionPool class from 1.0 has been removed. PooledSession
instances are acquired from the session pool (and must be released
appropriately). These are automatically refreshed (and eventually
evicted) by the session pool.
The ExecuteSqlStream and GetSqlStreamReader methods on
SpannerClient have been removed, along with
SpannerClientSettings.ExecuteSqlStreamSettings. The
SpannerClient.ExecuteStreamingSql method is responsible for
executing SQL and returning the results in a stream;
the PooledSession.ExecuteSqlStreamReader method returns a
ReliableStreamReader.
SpannerSettings.AllowImmediateTimeouts has been removed; this is
now solely in the ADO.NET provider.
Changes in Google.Cloud.Spanner.V1.Internal
The Google.Cloud.Spanner.V1 package exposes some types in the
Google.Cloud.Spanner.V1.Internal namespace, for use by
Google.Cloud.Spanner.Data. These types were not intended for
use by third-party code, so this document does not go into detail
around the changes in this namespace.
Execution-time behavior changes
Null values are returned as DBNull.Value by default rather
than the CLR default value for the type. Array and struct elements
use a null value where feasible, but throw InvalidCastException
when requested to be converted to a non-nullable value type. The
1.0 behavior can be requested using the UseClrDefaultForNullconnection string option.
Hashtable is no longer used as a default type for
struct values. It can still be specified explicitly.
The new default is Dictionary<string, object>.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version available is 5.0.0-beta05, and a range of versions are listed, extending back to 3.5.0, each with links to migration documentation.\u003c/p\u003e\n"],["\u003cp\u003eVersion 2.0 of Google.Cloud.Spanner.Data introduces several breaking changes compared to version 1.0, primarily in configuration, connection, command, transaction types, and a few miscellaneous areas.\u003c/p\u003e\n"],["\u003cp\u003eConfiguration changes include the removal of \u003ccode\u003eSpannerOptions\u003c/code\u003e and \u003ccode\u003eClientPool\u003c/code\u003e, with their functionalities replaced or moved to \u003ccode\u003eSessionPoolOptions\u003c/code\u003e, connection strings, or \u003ccode\u003eSessionPoolManager\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThere are breaking changes in connection, command, and transaction types such as the removal of \u003ccode\u003eSpannerCommandTextBuilder(string)\u003c/code\u003e constructor and the change in \u003ccode\u003eSpannerTransaction.CommitAsync\u003c/code\u003e return type.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eGoogle.Cloud.Spanner.V1\u003c/code\u003e package also has significant internal changes, including a new \u003ccode\u003eSessionPool\u003c/code\u003e implementation and modifications to streaming SQL methods, which are outlined for low-level users.\u003c/p\u003e\n"]]],[],null,["Version latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/migration-to-2)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/5.0.0/migration-to-2)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.6.0/migration-to-2)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.5.0/migration-to-2)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.4.0/migration-to-2)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.3.0/migration-to-2)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.2.0/migration-to-2)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.1.0/migration-to-2)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.0.0/migration-to-2)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.15.1/migration-to-2)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.14.0/migration-to-2)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.13.0/migration-to-2)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.12.0/migration-to-2)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.11.0/migration-to-2)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.10.0/migration-to-2)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.9.0/migration-to-2)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.8.0/migration-to-2)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.7.0/migration-to-2)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.6.0/migration-to-2)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.5.0/migration-to-2) \n\nMigration to Google.Cloud.Spanner.Data 2.0\n==========================================\n\nGoogle.Cloud.Spanner.Data version 2.0 includes a number of breaking\nchanges compared with version 1.0. We expect that most users will\nnot be affected by these changes, particularly when default settings\nare used. For users who are affected, this document should help you\nto migrate your application to the 2.0 version of the libraries.\n\nIf you have any problems with the breaking changes and they're not\ncovered in this document, please [file an\nissue](https://github.com/googleapis/google-cloud-dotnet/issues/new)\nso we can help you further.\n\nConfiguration changes\n---------------------\n\n- `SpannerOptions` has been removed completely. See the [configuration\n guide](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/configuration) for more details, but for migration purposes:\n - `KeepAliveInterval` is replaced by `SessionPoolOptions.IdleSessionRefreshDelay`\n - `MaximumPooledSessions` has no direct equivalent in 2.0; once a session is part of the pool, it will be refreshed as necessary until it is evicted.\n - `MaximumActiveSessions` is now only present in `SessionPoolOptions`\n - `MaximumGrpcChannels` is specified in the connection string\n - `LogLevel` is controlled on a per-logger basis; this property on `SpannerOptions` was equivalent to changing `Logger.DefaultLogger.LogLevel`.\n - `PoolEvictionDelay` is now only present in `SessionPoolOptions`\n - `ResourcesExhaustedBehavior` has moved to `SessionPoolOptions`\n - `Timeout` is specified in the connection string\n - `MaximumConcurrentSessionCreates` is now only present in `SessionPoolOptions`\n- `ClientPool` has been removed in 2.0. Its functionality has largely been replaced by `SessionPoolManager`. It is expected that the default session pool manager will be appropriate for most use cases, but you can associate a `SessionPoolManager` with the `SpannerConnectionStringBuilder` used to build a connection for more advanced situations.\n- `ResourcesExhaustedBehavior` has moved to Google.Cloud.Spanner.V1, as it is now configured in `SessionPoolOptions`.\n- Loggers are configured on a `SessionPoolManager` basis\n\nBreaking changes in connection, command and transaction types\n-------------------------------------------------------------\n\n- The `SpannerCommandTextBuilder(string)` constructor has been removed. The equivalent functionality is available via the static `SpannerCommandTextBuilder.FromCommandText` method.\n- `SpannerTransaction.CommitAsync` returns a `Task\u003cDateTime\u003e` rather than a `Task\u003cDateTime?\u003e`. The server will always return a commit timestamp, so the task's result would never have been null in 1.0 anyway. Client code should be able to use the resulting `Task\u003cDateTime\u003e` more easily in most cases.\n- `SpannerConnection` and `SpannerConnectionStringBuilder` no longer expose `GetCredentials` method. There is no direct equivalent in 2.0; please file an issue if you rely on this functionality.\n- `SpannerConnection.ClearPooledResourcesAsync` is replaced by `SpannerConnection.ShutdownSessionPoolAsync`. After this is called, no further sessions can be created with the associated session pool. If you need to control sessions in a more fine-grained way (for example, shutting down one session pool but then creating new sessions) you can associate a new `SessionPoolManager` instance with the `SpannerConnectionStringBuilder` used to build a connection. See the [configuration guide](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/configuration) for an example of this.\n- `SpannerTransaction.CommitAsync` now accepts a cancellation token. This defaults to `CancellationToken.None`, so existing source code should still compile, but this is a binary-incompatible change.\n\nMiscellaneous breaking changes\n------------------------------\n\n- `SpannerDbType.StructOf` has been replaced by `SpannerDbType.ForStruct`, using the new `SpannerStruct` type.\n- .NET Standard 1.5 is no longer supported; only .NET 4.5 and .NET Standard 2.0 are supported targets.\n\nBreaking changes in Google.Cloud.Spanner.V1\n-------------------------------------------\n\nUsers of the ADO.NET implementation in Google.Cloud.Spanner.Data\nwill rarely need to directly refer to the types in\nGoogle.Cloud.Spanner.V1, but some low-level users may wish to do so.\n\nThe previous `Google.Cloud.Spanner.V1.SessionPool` class has been\nreplaced by a completely new implementation, with a new API and some\nchanges to the corresponding `SessionPoolOptions` class. The new\n`SessionPool` manages transactions as well as sessions, so the\n`TransactionPool` class from 1.0 has been removed. `PooledSession`\ninstances are acquired from the session pool (and must be released\nappropriately). These are automatically refreshed (and eventually\nevicted) by the session pool.\n\nThe `ExecuteSqlStream` and `GetSqlStreamReader` methods on\n`SpannerClient` have been removed, along with\n`SpannerClientSettings.ExecuteSqlStreamSettings`. The\n`SpannerClient.ExecuteStreamingSql` method is responsible for\nexecuting SQL and returning the results in a stream;\nthe `PooledSession.ExecuteSqlStreamReader` method returns a\n`ReliableStreamReader`.\n\n`SpannerSettings.AllowImmediateTimeouts` has been removed; this is\nnow solely in the ADO.NET provider.\n\nChanges in Google.Cloud.Spanner.V1.Internal\n-------------------------------------------\n\nThe Google.Cloud.Spanner.V1 package exposes some types in the\nGoogle.Cloud.Spanner.V1.Internal namespace, for use by\nGoogle.Cloud.Spanner.Data. These types were not intended for\nuse by third-party code, so this document does not go into detail\naround the changes in this namespace.\n\nExecution-time behavior changes\n-------------------------------\n\n- Null values are returned as `DBNull.Value` by default rather than the CLR default value for the type. Array and struct elements use a null value where feasible, but throw `InvalidCastException` when requested to be converted to a non-nullable value type. The 1.0 behavior can be requested using the `UseClrDefaultForNull` [connection string option](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/connection_string).\n- `Hashtable` is no longer used as a default type for struct values. It can still be specified explicitly. The new default is `Dictionary\u003cstring, object\u003e`."]]