Sql-server – Data Tier Applications (DAC) on replicated databases

data-tier-applicationreplicationsql server

We are exploring options to accomplish 3 things: 1) source control the database, 2) centralize and coordinate all database changes and tie them to application changes, and 3) automate database deployments.

I'm considering using DACPACS for this but we have 4 production databases that have replication between themselves set in place. The replication was set up a long time ago and was implemented in an odd fashion. Essentially, not all 4 databases are exactly the same. Some data is replicated and some is not.

My question is about applying DACPACS. If we were to apply the DACPACs to each database during a deployment, how would this affect replication?

Thanks

Best Answer

The short answer is: SSDT (dacpacs) does not support SQL Server replication.

The longer answer is that you might be able to work around this limitation by using pre and post deploy scripts. And maybe write your own deployment contribution extension to handle replicated objects better.

For the pre and post deploys scripts approach you could write something that captures the current replication state (publications, articles, subscribers and subscriptions) and then pulls all that down. Then the dacpac updates the current schema and a post deploy script(s) recreates the replication.

If you're strict on your replication topology and configuration this could work. It won't be easy though! Another similar approach, which would also buy into your "get the database under souce control" is you only allow replication to be configured from scripts and these become your pre/post deploy changes (much like above but less dynamic work).

Another approach would be to use another system for database control and deployments. Something like:

These both take the database migrations approach rather than model first approach. These would probably make the replication aspects easier to handle.