SQL Azure Database: Unable to restore bacpac due to foreign key conflict.

0 votes

I'm attempting to restore a backup (.bacpac) of one SQL Azure database to another SQL Azure database but I am getting the following error:

Error encountered during the service operation. Could not import package. 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_x_xx". The conflict occurred in database "x", table "dbo.x". Error SQL72045: Script execution error. The executed script: PRINT N'Checking constraint: FK_x_xx[dbo].[x]'; ALTER TABLE [dbo].[x] WITH CHECK CHECK CONSTRAINT [FK_x_xx];

I have also attempted to restore locally without success with a mscorlib exception. And I've also checked the live database and I can't see why this key is being violated.

Apr 2 in Azure by sabby
• 4,050 points
32 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Since tha bacpac file is not transactional, so when the bacpac is being generated, writing new rows to your target database will end up corrupting the index. The database should either have no other users, or it should be copied and a bacpac should be made from the copy.

1. Copy the target database (the database will take some time to copy), The following operation will create a full transactional copy:

CREATE DATABASE <name> AS COPY OF <original_name>

2. Find the status of your copy operation:

SELECT * FROM sys.dm_database_copies

3. Generate a bacpac file on the copied database, which isn't being used by anyone

4. Delete the copied database, and you'll have a working bacpac file

You can see the progress of the copy in their portal.

answered Apr 2 by Prerna
• 1,940 points

Related Questions In Azure

0 votes
1 answer

How to restore SQL Server .bak file to Azure SQL Database?

Azure SQL Database does not currently support ...READ MORE

answered Jul 3, 2018 in Azure by club_seesharp
• 3,450 points
1,769 views
+1 vote
1 answer

How to copy Azure SQL database to a local development server?

Actually, there are multiple ways to do ...READ MORE

answered Jul 9, 2018 in Azure by null_void
• 3,220 points
81 views
0 votes
1 answer

How can I copy SQL Azure database to a local development server?

There are certain ways to do this: Using SSIS ...READ MORE

answered Jun 26, 2018 in Azure by null_void
• 3,220 points
33 views
0 votes
1 answer

How can we connect Azure Web App to an Azure SQL Database?

Its easy now! Go to your Azure SQL ...READ MORE

answered Aug 8, 2018 in Azure by club_seesharp
• 3,450 points
66 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

There may be an issue with the ...READ MORE

answered Mar 6 in Azure by Prerna
• 1,940 points
13 views
0 votes
1 answer

Azure Storage Emulator shows error.

This blog might help with your query: http://blog.smarx.com/posts/windows-azure-storage-emulator-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process Also, ...READ MORE

answered Mar 15 in Azure by Prerna
• 1,940 points
23 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

Azure blobs can be downloaded in four ...READ MORE

answered Mar 15 in Azure by Prerna
• 1,940 points
25 views
0 votes
1 answer

How to debug Azure 500 internal server error?

You can simply turn off custom error in ...READ MORE

answered Mar 29 in Azure by Prerna
• 1,940 points
26 views
0 votes
1 answer

How to query between databases in SQL Azure Database Server?

SQL Azure supports cross database queries: https://azure.micros ...READ MORE

answered Apr 9 in Azure by Prerna
• 1,940 points
16 views
0 votes
1 answer

How do disconnect to Azure SQL database if I can't access it?

Based on info  from Microsoft, I think ...READ MORE

answered Apr 26 in Azure by Prerna
• 1,940 points
44 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.