Remove data from BACPAC file

Remove data from BACPAC file

Today I needed to create a test database for one of the products I’m working on. In the backend it uses LINQ to SQL against a SQL Azure Database. Exporting the production database and cleaning it up with millions of records in it turned out to be not the most efficient way of creating an empty test database.

I ended up modifiying the BACPAC file that is generated by the export functionality available through Azure Portal (and PowerShell / CLI).

To simply remove all data and just keep the model follow these steps:

  1. Download the .bacpac file from blob storage
  2. Unzip the .bacpac file (you may have to rename to .zip)
  3. Delete everything under /Data
  4. Replace the content of _rels/.rels with the following
<?xml version="1.0" encoding="utf-8"?>
<Relationships xmlns="">
  1. Zip everything (but make sure to not include a directory in the archive)

You can now use PowerShell or CLI to import the empty BACPAC file to your database.