无法将SQL Azure bacpac导入2016 CTP

时间:2022-05-11 05:31:39

I'm very familiar with the process of exporting from Azure SQL V12 down to my dev box and then importing to my local sql (2014) instance. I'm spinning up a new Win10 box and have installed the SQL 2016 CTP. I'm connecting to that same Azure instance and can operate against it -- and can export a .bacpac just as with 2014.

我非常熟悉从Azure SQL V12导出到我的开发箱然后导入到我的本地sql(2014)实例的过程。我正在启动一个新的Win10盒子并安装了SQL 2016 CTP。我正在连接到同一个Azure实例并可以对其进行操作 - 并且可以像2014年一样导出.bacpac。

But when I try to import to local I'm getting:

但是,当我尝试导入到本地时,我得到:

Could not import package.
Warning SQL72012: The object [FOO33_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 [FOO33_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 547, Level 16, State 0, Line 3 The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_dbo.Address_dbo.User_idUser". The conflict occurred in database "FOO33", table "dbo.User", column 'idUser'.
Error SQL72045: Script execution error.  The executed script:
PRINT N'Checking constraint: FK_dbo.Address_dbo.User_idUser [dbo].[Address]';

ALTER TABLE [dbo].[Address] WITH CHECK CHECK CONSTRAINT [FK_dbo.Address_dbo.User_idUser];

1 个解决方案

#1


5  

Since this question was also asked and answered on MSDN, I will share here. https://social.msdn.microsoft.com/Forums/azure/en-US/0b025206-5ea4-4ecb-b475-c7fabdb6df64/cannot-import-sql-azure-bacpac-to-2016-ctp?forum=ssdsgetstarted

由于这个问题也在MSDN上被询问和回答,我将在这里分享。 https://social.msdn.microsoft.com/Forums/azure/en-US/0b025206-5ea4-4ecb-b475-c7fabdb6df64/cannot-import-sql-azure-bacpac-to-2016-ctp?forum=ssdsgetstarted

Text from linked answer:

来自链接答案的文字:

I suspect what's going wrong here is that the export operation was performed using a DB instance that was changing while the export was on-going. This can cause the exported table data to be inconsistent because, unlike SQL Server's physical backup/restore, exports do not guarantee transactional consistency. Instead, they're essentially performed by connecting to each table in the database in turn and running select *. When a foreign key relationship exists between two tables and the read table data is inconsistent, it results in an error during import after the data is written to the database and the import code attempts to re-enable the foreign key. We suggest using the database copy mechanism (create database copyDb as copy of originalDb), which guarantees a copy with transactional consistency, and then exporting from the non-changing database copy.

我怀疑这里出现的问题是导出操作是使用在导出正在进行时更改的数据库实例执行的。这可能导致导出的表数据不一致,因为与SQL Server的物理备份/还原不同,导出不保证事务一致性。相反,它们基本上是通过依次连接到数据库中的每个表并运行select *来执行的。当两个表之间存在外键关系并且读取表数据不一致时,在将数据写入数据库并导入代码尝试重新启用外键后导入期间会导致错误。我们建议使用数据库复制机制(创建数据库copyDb作为originalDb的副本),这保证了具有事务一致性的副本,然后从不变的数据库副本导出。

#1


5  

Since this question was also asked and answered on MSDN, I will share here. https://social.msdn.microsoft.com/Forums/azure/en-US/0b025206-5ea4-4ecb-b475-c7fabdb6df64/cannot-import-sql-azure-bacpac-to-2016-ctp?forum=ssdsgetstarted

由于这个问题也在MSDN上被询问和回答,我将在这里分享。 https://social.msdn.microsoft.com/Forums/azure/en-US/0b025206-5ea4-4ecb-b475-c7fabdb6df64/cannot-import-sql-azure-bacpac-to-2016-ctp?forum=ssdsgetstarted

Text from linked answer:

来自链接答案的文字:

I suspect what's going wrong here is that the export operation was performed using a DB instance that was changing while the export was on-going. This can cause the exported table data to be inconsistent because, unlike SQL Server's physical backup/restore, exports do not guarantee transactional consistency. Instead, they're essentially performed by connecting to each table in the database in turn and running select *. When a foreign key relationship exists between two tables and the read table data is inconsistent, it results in an error during import after the data is written to the database and the import code attempts to re-enable the foreign key. We suggest using the database copy mechanism (create database copyDb as copy of originalDb), which guarantees a copy with transactional consistency, and then exporting from the non-changing database copy.

我怀疑这里出现的问题是导出操作是使用在导出正在进行时更改的数据库实例执行的。这可能导致导出的表数据不一致,因为与SQL Server的物理备份/还原不同,导出不保证事务一致性。相反,它们基本上是通过依次连接到数据库中的每个表并运行select *来执行的。当两个表之间存在外键关系并且读取表数据不一致时,在将数据写入数据库并导入代码尝试重新启用外键后导入期间会导致错误。我们建议使用数据库复制机制(创建数据库copyDb作为originalDb的副本),这保证了具有事务一致性的副本,然后从不变的数据库副本导出。