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:
- Download the .bacpac file from blob storage
- Unzip the .bacpac file (you may have to rename to .zip)
- Delete everything under /Data
- Replace the content of _rels/.rels with the following
<?xml version="1.0" encoding="utf-8"?>
- 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.