英文:
dacpac installation failed with Unable to reconnect to database: Execution Timeout Expired
问题
在使用C#中的DacServices.Deploy发布dacpac时,遇到了超时错误。代码最近迁移到了.NET Core。我们正在发布到一个新的SQL Server 2022数据库,这是我们首次部署到SQL Server。
以下是代码部分:
Log.Info($"Loading DACPAC...: {dacpacPath}...");
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.");
以下是异常的详细信息。
英文:
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 ---
答案1
得分: 0
这个问题已解决,我使用了错误的连接字符串。
英文:
This issue is solved, I was using wrong connection string.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论