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=truewill drop the user/login objects on TargetDb which is absolutely not expected! The closest ones I can find is/p:DropRoleMembersNotInSource=false /p:DropPermissionsNotInSource=falsebut those do not help much. - The flag
/p:DropObjectsNotInSource=truewill break the flag/p:BlockOnPossibleDataLoss=truewhich 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?

I asked a similar question here and ended up scripting the users as a post-deploy script to recreate them after deploying the database upgrade.
The
DropPermissionsNotInSourceproperty only applies toGRANT/DENYpermissions.DropRoleMembersNotInSourceis just for role membership.Sadly there isn't an option to exclude users from the objects being dropped when the
DropObjectsNotInSourceproperty is set to true.We also make certain changes (like changing column types) in pre-deploy scripts, as
BlockOnPossibleDataLosscan prevent deployment even when the change won't cause data loss. I guess it's good it's over cautious rather than not cautious enough.