A .NET 8 command-line tool for editing SQL Server BACPAC files by removing specific database objects like stored procedures, views, functions, and more.
When exporting a database as a BACPAC file, SQL Server includes everything.. tables, stored procedures, views, functions, triggers, constraints, and more. Sometimes you only want to import specific parts of the database, but BACPAC files don't allow selective imports.
Common scenarios where BacpacEditor helps:
- Data migration: You want to import only tables and data, not stored procedures or views
- Development environments: Remove production-specific stored procedures before importing to dev
- Clean database setup: Import only the schema without business logic (stored procedures/functions)
- Compliance: Remove sensitive stored procedures before sharing database exports
- Testing: Create test databases without certain objects that might interfere with testing
- .NET 8.0 SDK or later
git clone <repository-url>
cd BacpacEditor
dotnet builddotnet run -- <file-path> <selection-options>| Option | Description |
|---|---|
--Views |
Remove all views |
--StoredProcedures |
Remove all stored procedures |
--Functions |
Remove all functions (scalar, table-valued, etc.) |
--Tables |
Remove all tables |
--Indexes |
Remove all indexes |
--Constraints |
Remove all constraints |
--Triggers |
Remove all triggers |
--Schemas |
Remove all schemas |
--Users |
Remove all users |
--Roles |
Remove all roles |
--AllObjects |
Remove all database objects |
dotnet run -- "database.bacpac" "--Views" "--StoredProcedures"dotnet run -- "database.bacpac" "--Functions" "--Triggers"dotnet run -- "database.bacpac" "--Views" "--StoredProcedures" "--Functions" "--Triggers" "--Indexes" "--Constraints"dotnet run -- "model.xml" "--Views"- Extracts the BACPAC file (which is a ZIP archive)
- Modifies the
model.xmlfile to remove specified elements - Updates the
origin.xmlfile with new checksums and object counts - Repackages everything into a new
_modified.bacpacfile - Cleans up temporary files
- Loads the XML file
- Removes specified elements based on Type attributes
- Saves the modified XML file