Reputation: 89
when publishing a dacpac using DacServices.Deploy in C#, getting timeout error. Code recently migrated to .NET core. We're publishing into a new SQL Server 2022 database and this is first time we are deploying to SQL server.
code
var package = DacPackage.Load(dacpacPath);
if (package == null)
{
throw new Exception("Error loading DACPAC");
}
Log.Info($"DACPAC loaded....: Version='{package.Version}', Name='{package.Name}'");
Log.Info("Deploying DACPAC to server...");
var options = new DacDeployOptions()
{
BlockOnPossibleDataLoss = true
};
var services = new DacServices(setup.ConnectionString);
services.Message += Services_Message;
services.ProgressChanged += Services_ProgressChanged;
var builder = new SqlConnectionStringBuilder(setup.ConnectionString);
services.Deploy(package: package, targetDatabaseName: builder.InitialCatalog, upgradeExisting: false, options);
Log.Info("DACPAC deployed to server.");
below is the exception details.
Microsoft.SqlServer.Dac.DacServicesException: An error occurred during deployment plan generation. Deployment cannot continue.
---> Microsoft.Data.Tools.Schema.Sql.Deployment.DeploymentFailedException: Unable to reconnect to database: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
---> Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerException: Unable to reconnect to database: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
---> Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
---> System.ComponentModel.Win32Exception (258): Unknown error 258
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()
at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader()
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerImpl.ExecutePopulators(Tuple`2 connectionTuple, IList`1 populators, Int32 totalPopulatorsCount, Int32 startIndex, Boolean progressAlreadyUpdated, ReverseEngineerOption option, SqlReverseEngineerRequest request)
ClientConnectionId:b869fd60-a7a4-4baa-9e6f-0c985fa1b68e
Error Number:-2,State:0,Class:11
--- End of inner exception stack trace ---
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerImpl.ExecutePopulatorsInPass(SqlReverseEngineerConnectionContext context, ReverseEngineerOption option, SqlReverseEngineerRequest request, Int32 totalCount, Tuple`2[] populatorsArray)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerImpl.PopulateBatch(SqlReverseEngineerConnectionContext context, SqlSchemaModel model, ReverseEngineerOption option, ErrorManager errorManager, SqlReverseEngineerRequest request, SqlImportScope importScope)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineer.PopulateAll(SqlReverseEngineerConnectionContext context, ReverseEngineerOption option, ErrorManager errorManager, Boolean filterManagementScopedElements, SqlImportScope importScope, Boolean optimizeForQuery, ModelStorageType modelType)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.ImportDatabase(SqlReverseEngineerConstructor constructor, DeploymentEngineContext context, ErrorManager errorManager)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.CreateNewModel(ErrorManager errors, DeploymentEngineContext context)
--- End of inner exception stack trace ---
Upvotes: 0
Views: 332
Reputation: 89
This issue is solved, I was using wrong connection string.
Upvotes: 0