private async Task PrepareAsync(CancellationToken cancellationToken) { Session.EnsureNotDisposed(); await driver.OpenConnectionAsync(Session, connection, cancellationToken).ConfigureAwait(false); try { foreach (var initializationSqlScript in initializationSqlScripts) { using (var command = connection.CreateCommand(initializationSqlScript)) await driver.ExecuteNonQueryAsync(Session, command, cancellationToken).ConfigureAwait(false); } } catch (OperationCanceledException) { connection.Close(); throw; } if (pendingTransaction == null) { return; } var transaction = pendingTransaction; pendingTransaction = null; if (connection.ActiveTransaction == null) // Handle external transactions { driver.BeginTransaction(Session, connection, IsolationLevelConverter.Convert(transaction.IsolationLevel)); } }