title: Error 'Could not open a connection to SQL Server' while upgrading database with codefluent pivot runner
body: <p>We use the pivot runner to update our databases. Since a year we regularly receive error message below. The database server is available, and is hardly used by other processes. After restarting, the same message usually reappears several times, but not always with the same action. As soon as we have managed to update the first database, updating the other (40+) databases also runs smoothly.
  Any idea what could be the cause of this?</p>
  <pre><code>System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The ser
  ver was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: N
  amed Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---&gt; System.ComponentModel.Win32Exception (0x80004005): Access is denied
     at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential
  , Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, Session
  Data reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderMa
  nager)
     at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbC
  onnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
     at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOpti
  ons userOptions)
     at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOpti
  ons, DbConnectionInternal oldConnection, DbConnectionInternal&amp; connection)
     at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskComple
  tionSource`1 retry, DbConnectionOptions userOptions)
     at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
  `1 retry, DbConnectionOptions userOptions)
     at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
     at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
     at System.Data.SqlClient.SqlConnection.Open()
     at CodeFluent.Runtime.Database.Management.Database.GetSchema(String collectionName, String[] restrictionValues)
     at CodeFluent.Runtime.Database.Management.SqlServer.Key.Construct(DataRow row)
     at CodeFluent.Runtime.Database.Management.Key..ctor(Table table, DataRow row)
     at CodeFluent.Runtime.Database.Management.SqlServer.Table.NewKey(DataRow row)
     at CodeFluent.Runtime.Database.Management.SqlServer.Table.GetKeys()
     at CodeFluent.Runtime.Database.Management.Table.get_Keys()
     at CodeFluent.Runtime.Database.Management.Database.ResolveReferencingKeys(Boolean refresh)
     at CodeFluent.Runtime.Database.Management.Table.get_ReferencingForeignKeys()
     at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.&lt;GetConstraintReferencingKeys&gt;d__6.MoveNext()
     at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.DropConstraint(String tableSchema, String tableName, String constraintName, DistinctDictio
  nary`1 constraints)
     at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.DropConstraint(String tableSchema, String tableName, String constraintName)
     at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.UpdateColumn(PivotRunnerColumn column, Column existingColumn)
     at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.UpdateTable(PivotRunnerTable table, Table existingTable)
     at CodeFluent.Runtime.Database.Management.SqlServer.PivotRunner.Run()
  </code></pre>