导入数据层应用程序失败

Import data tier application is failing

我在将数据库备份(.bacpac 文件)还原到我的本地 SQL Server 2016 实例时遇到以下错误。

TITLE: Microsoft SQL Server Management Studio

Could not import package.

Warning SQL72012: The object [Azure_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.

Warning SQL72012: The object [Azure_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.

Error SQL72014: .Net SqlClient Data Provider:

Msg 33161, Level 15, State 1, Line 1
Database master keys without password are not supported in this version of SQL Server.

Error SQL72045: Script execution error. The executed script: CREATE MASTER KEY;

这是由于 SQL Azure 和 SQL Server 2016 之间的差异。拥有没有密码的主密钥是 Azure 独有的功能。有两种方法可以解决这个问题。

1) 打开 .bacpac 并删除主密钥对象和凭据对象。 (将 .bacpac 重命名为 .zip,解压缩,然后查看 xml 文件,进行必要的更改,压缩备份并重命名回 .bacpac)

2) 在使用以下方法将数据库导出到 .bacpac 之前,将密码加密添加到主密钥: ALTER MASTER KEY ADD ENCRYPTION BY PASSWORD = '<PasswordHere>';

现在有一个更简单的解决方案。下载 SSMS 的更新...至少版本 14.0.17277.0。这样您就不必摆弄主密钥或修补 bacpac 文件。简单多了。