Is it possible to apply filters on SqlPackage?

Posted on

Question :

We develop a lot of modules separately. This means the Blog module has its own database in development. All objects of each module start with the module schema. So the Posts table inside the Blog module is named blog.Posts.

However, in production we deploy all modules to one target database.

For example, this means that in production I will have these objects:

blog.Posts
content.Pages
seo.Configurations
menu.Items
email.Templates

Now, I want to compare Blog module database with the production database. I’m using SqlPackage for this purpose.

The point is that SqlPackage creates a huge drop script, because it thinks that all other tables from other modules that exist in the production database should be dropped.

Is there a way to tell SqlPackage to only compare the objects of a given schema? Can I configure SqlPackage to only compare blog schema?

Answer :

Check out the DropObjectsNotInSource option to Script and Publish actions in SqlPackage.exe:

/p: DropObjectsNotInSource=(BOOLEAN)

Specifies whether objects that do not exist in the database snapshot
(.dacpac) file will be dropped from the target database when you
publish to a database. This value takes precedence over
DropExtendedProperties.

Leave a Reply

Your email address will not be published. Required fields are marked *