Quantcast
Viewing all articles
Browse latest Browse all 77

“Could not import package” when restoring a Windows Azure SQL Database Export

One of my customers encountered some issues when trying to restore a Windows Azure SQL Database export:

Image may be NSFW.
Clik here to view.

If we take a closer look at the error for the Importing database operation we’ll see the following:

Could not import package… ‘get_new_rowversion’ is not a recognized built-in function name.

Image may be NSFW.
Clik here to view.

According to the error message and a few posts on the MSDN forum this exception is caused due to the fact that Data Sync had previously been enabled on this database and the get_new_rowversion function is not available when restoring the database. Since this function simply returns a BIGINT you can easily replace it with a zero.

A bacpac file is actually a Package (you’ll find that class in the System.IO.Packaging namespace), so you can open and edit the file using managed code. That’s why I created a simple console application that:

  • Replaces all calls to get_new_rowversion() to 0 (zero) in the model.xml file
  • Updates the checksum for the model.xml file in the Origin.xml file

The complete source for this application is available on GitHub: https://github.com/sandrinodimattia/WindowsAzure-SqlDatabaseExportFix. The binaries can be downloaded here.

The tool takes 1 parameter: the path to the *.bacpac file. If you run the tool it will go through the *.bacpac file, make the required changes and update the export. I suggest you take a backup of the export just to be sure.

Image may be NSFW.
Clik here to view.

After that you’ll be able to import the BACPAC using the “Import Data-tier application” wizard:

Image may be NSFW.
Clik here to view.

Enjoy!


Viewing all articles
Browse latest Browse all 77

Trending Articles