SqlPackage is the descendant of VsDbCmd command-line tool. It creates, deploys, and packages SQL Server databases snapshots into a portable artifact called a DAC package, also known as a DACPAC.
Manual Database Schema Synchronization
SQL Server Database Project
Local
column the path of SQL Server installation folder. Notice that the Local path overrides the Default
path.SQL > Schema Compare > New Schema Comparison
Automatic Database Schema Synchronization
When there is no network access in production environment, the synchronization process can be automated.
Thanks to Dimitris Charalampidis who provided the steps below, the database schema synchronization can be automated as follows:
sqlpackage.exe /a:Script /sf:[Yourdatabaseproject.dacpac] /tcs:"Data Source=[connectionString]" /op:DBSchemaCompareScript.sql /p:ScriptDeployStateChecks=True /p:BackupDatabaseBeforeChanges=True /p:IgnoreExtendedProperties=True /p:IgnorePermissions=True /p:IgnoreRoleMembership=True /v:Path1="[Path1]" /v:Path2="[Path2]"
At this point you may want to add also the
/p:GenerateSmartDefaults=True
switch to provide a default value when updating a table that contains data with for columns that do not allow null values.
After a few seconds a file named DBSchemaCompareScript.sql will be created (you can change the name with the /op:
switch value).
Query > SQLCMD Mode
and execute the query.After the query executes without errors, the database schema will be synchronized with the latest changes.
Remarks
The following files are required by the SqlPackage if the Microsoft SQL Server Data Tools is not installed in production environment: