【问题标题】:DACPAC won't deploy because 'can't connect to server'?DACPAC 不会部署,因为“无法连接到服务器”?
【发布时间】:2016-06-27 09:30:12
【问题描述】:

我正在尝试将 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)

我错过了什么?

【问题讨论】:

    标签: visual-studio-2015 sql-server-data-tools localdb dacpac


    【解决方案1】:

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

    否则,请确认您使用的 LocalDB 版本是 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 工具中发布 SQL Server 2014 支持时,进行了更改,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,现在一切正常。
    • 我在使用 DacFX 120 连接到 SQL 2016 时遇到了同样的问题。更改为使用 DacFX 130(根据答案恰好安装在 Visual Studio 下)解决了这个问题。谢谢!
    【解决方案2】:

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

    谢谢, 钱达纳

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-22
      • 1970-01-01
      • 2021-05-02
      • 1970-01-01
      • 2021-03-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多