private async Task PrepareAsync(CancellationToken cancellationToken)
        {
            Session.EnsureNotDisposed();
            await driver.EnsureConnectionIsOpenAsync(Session, connection, cancellationToken).ConfigureAwait(false);

            try {
                foreach (var initializationSqlScript in initializationSqlScripts)
                {
                    var command = connection.CreateCommand(initializationSqlScript);
                    await using var commandAwaiter = command.ConfigureAwait(false);
                    await driver.ExecuteNonQueryAsync(Session, command, cancellationToken).ConfigureAwait(false);
                }
            }
            catch (OperationCanceledException) {
                await connection.CloseAsync().ConfigureAwait(false);

                throw;
            }

            if (pendingTransaction == null)
            {
                return;
            }

            var transaction = pendingTransaction;

            pendingTransaction = null;
            if (connection.ActiveTransaction == null)
            {
                // Handle external transactions
                var isolationLevel = IsolationLevelConverter.Convert(transaction.IsolationLevel);
                await driver.BeginTransactionAsync(Session, connection, isolationLevel, cancellationToken).ConfigureAwait(false);
            }
        }