DACPAC无法部署,因为“无法连接到服务器”?

9

我正在尝试将一个DACPAC部署到LocalDB 2012,但它似乎行不通:

堆栈跟踪如下:

==================================

Could not deploy package. (Microsoft.SqlServer.Dac)

------------------------------
Program Location:

   at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, Action`2 reportStatus, CancellationToken cancellationToken)
   at Microsoft.SqlServer.Dac.DacServices.InternalDeploy(IPackageSource packageSource, Boolean isDacpac, String targetDatabaseName, DacDeployOptions options, CancellationToken cancellationToken)
   at Microsoft.SqlServer.Dac.DacServices.Deploy(DacPackage package, String targetDatabaseName, Boolean upgradeExisting, DacDeployOptions options, Nullable`1 cancellationToken)
   at Microsoft.SqlServer.Management.Dac.DacWizard.DeployModel.Install()
   at Microsoft.SqlServer.Management.Dac.DacWizard.DeployModel.RunAction()
   at Microsoft.SqlServer.Management.Dac.DacWizard.ExecuteDacPage.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

===================================

Unable to connect to target server. (Microsoft.Data.Tools.Schema.Sql)

------------------------------
Program Location:

   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.OnInit(ErrorManager errors, String targetDBName)
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment..ctor(SqlDeploymentConstructor constructor)
   at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentConstructor.ConstructServiceImplementation()
   at Microsoft.SqlServer.Dac.DacServices.CreatePackageToDatabaseDeployment(String connectionString, IPackageSource packageSource, String targetDatabaseName, DacDeployOptions options, ErrorManager errorManager)
   at Microsoft.SqlServer.Dac.DeployOperation.<>c__DisplayClass4.<CreatePlanInitializationOperation>b__0(Object operation, CancellationToken token)
   at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.OperationExtension.CompositeOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.DeployOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)

现在因为我正在尝试通过 SSMS 部署,所以我知道我可以连接到服务器。我已经在 Visual Studio 中检查了解决方案,目标版本为 SQL Server 2012 并且连接字符串似乎是正确的。
有趣的是,通过 Visual Studio 进行部署是可行的,但是我无法将数据库升级为数据层应用程序,我收到如下消息:
===================================

Database source is not a supported version of SQL Server (localdb)\MYINSTANCE: . (Microsoft.SqlServer.Dac)
------------------------------
Program Location:

   at Microsoft.SqlServer.Dac.DacServices.GetDatabaseSchemaProvider(String connectionString)
   at Microsoft.SqlServer.Dac.DacServices.InternalRegister(String targetDatabaseName, String applicationName, Version applicationVersion, String applicationDescription, ModelStorageType modelStorageType)
   at Microsoft.SqlServer.Dac.DacServices.<>c__DisplayClass29.<Register>b__28(Object operation, CancellationToken token)
   at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
   at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, Action`2 reportStatus, CancellationToken cancellationToken)
   at Microsoft.SqlServer.Dac.DacServices.Register(String targetDatabaseName, DacSchemaModelStorageType modelStorageType, String applicationName, Version applicationVersion, String applicationDescription)
   at Microsoft.SqlServer.Management.Dac.DacWizard.RegisterModel.RunAction()
   at Microsoft.SqlServer.Management.Dac.DacWizard.ExecuteDacPage.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

我错过了什么?

2个回答

12

更新到最新版本的SSMS应该可以解决这个问题。它可以在这里获取:https://msdn.microsoft.com/en-us/library/mt238290.aspx

否则,请确认您正在使用LocalDB 2012版本。为此,您可以对服务器运行此查询:

select @@version
  • 11.0.xxxx = SQL Server 2012
  • 12.0.xxxx = SQL Server 2014
  • 13.0.xxxx = SQL Server 2016

负责处理dacpac部署的库称为数据层应用程序框架或 DacFX。SSMS 2012所使用的DacFX版本已安装在以下位置:

C:\program files (x86)\Microsoft Sql Server\110\DAC\bin

注意路径中的“110”,表示DacFX版本支持SQL Server 2012。 SSMS 2014 在类似的路径下查找DacFX,但在"120"文件夹中,而该版本的DacFX支持SQL Server 2014等更高版本。

当向新版本服务器部署时,如果DacFX无法支持,则会显示“无法连接”错误消息。(顺便说一下,新版DacFX改进了错误消息)

曾经,Visual Studio使用上述路径中安装的DacFX版本,但大约在发布SQL Server 2014支持的SQL Server工具时,进行了更改,Visual Studio获得了自己的DacFX副本:

C:\program files (x86)\Microsoft Visual Studio XX.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120

这就是如何在不同版本的Visual Studio和SSMS之间获得不同行为的方式。


结果发现我在这里犯了一个错误,v11是SQL 2012而不是v12。哎呀 : ) 我卸载了LocalDB 2014(我不知道我什么时候安装的),修复了LocalDB 2012,现在一切都很好。 - Jake
我曾经遇到过同样的问题,使用DacFX 120连接SQL 2016时出现了问题。改用DacFX 130(正如答案所述,在Visual Studio下安装)解决了这个问题。谢谢! - Rory

0

我曾经遇到同样的问题,通过将可执行文件夹从“C:\program files (x86)\Microsoft Sql Server\110\DAC\bin”更改为“C:\program files (x86)\Microsoft Sql Server\120\DAC\bin”,问题得以解决。

谢谢, Chandana


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接