As we can use SqlPackage.exe
from Microsoft SSDT in Visual Studio 2012 to sync database as discussed here, I'm using it to sync target database, called TargetDb
, to match with the source database objects stored in an SQL Server Database project, called DbProject
.
The action /a:Publish
of SqlPackage.exe
command allows us to sync the DbProject's .dacpac file to TargetDb but the default arguments will NOT drop TargetDb's objects which not exist in DbProject.
Turning on the flag /p:DropObjectsNotInSource=true
will solve this but also creates weird behaviors
- The flag
/p:DropObjectsNotInSource=true
will drop the user/login objects on TargetDb which is absolutely not expected! The closest ones I can find is/p:DropRoleMembersNotInSource=false /p:DropPermissionsNotInSource=false
but those do not help much. - The flag
/p:DropObjectsNotInSource=true
will break the flag/p:BlockOnPossibleDataLoss=true
which means if data-loss occurs, the update action(s) will not be blocked; that is NOT what I want at all.
Currently I have to accept 'trash'/redundant objects on TargetDb :(
What are better flags to use to get me there?