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

时间:2016-03-12 00:03:52

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

我正在尝试将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 个答案:

答案 0 :(得分:9)

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

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

$work_list[] = $row["work" . $i];
  • 11.0.xxxx = SQL Server 2012
  • 12.0.xxxx = SQL Server 2014
  • 13.0.xxxx = SQL Server 2016

处理dacpac部署的库称为数据层应用程序框架或DacFX。 SSMS 2012使用的DacFX版本安装在:

$work_list = array();
$work_names = array();
for ($i=1; $i <= 11 ; $i++) {
    $work_names[] = "work$i";
}
$work_name_string = implode(', ', $work_names);
$query_work = mysql_query("SELECT DISTINCT $work_name_string FROM Test;"); 
while ($row = mysql_fetch_array($query_work)) {
    for ($i=1; $i <= 11 ; $i++) {
        $work_list[]= $row["work$i"];
    }
}

$work_list=array_merge(array_unique($work_list));

注意路径中的“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
select @@version

因此,您可以在不同版本的Visual Studio和SSMS之间获得不同的行为。

答案 1 :(得分:0)

我遇到了同样的问题,通过更改&#34; C:\ program files(x86)\ Microsoft Sql Server \ 110 \ DAC \ bin&#34;中的可执行文件夹来解决此问题。到&#34; C:\ program files(x86)\ Microsoft Sql Server \ 120 \ DAC \ bin&#34;

谢谢, Chandana