我正在尝试通过代码将 dacpac 部署到 SQL 2014。它与 Windows 身份验证完美配合,但是当我使用 SQL 服务器身份验证时,我收到以下错误:
无法部署包。内部异常:无法连接到目标服务器。
我可以使用该用户登录 SQL Management Studio 并部署 dacpac,没有任何问题。
作品:
Data Source=JJ_LAPTOP\SQLEXPRESS;Initial Catalog=BioMasterMain;Integrated Security=True;
不起作用:
Data Source=JJ_LAPTOP\SQLEXPRESS;Initial Catalog=BioMasterMain;User ID=sample;Password=sample;
代码:
var databaseVersion = GetCurrentDacVersionFromDatabase(dbConnString);
var dacPackage = DacPackage.Load(dacPacPath);
if (dacPackage.Version > databaseVersion)
{
var dacServices = new DacServices(dbConnString);
// Change any dacDeployOptions here.
var dacDeployOptions = new DacDeployOptions {RegisterDataTierApplication = true};
dacServices.Deploy(dacPackage, "BioMasterMain", true, dacDeployOptions); <-- Fails here
}