Switch from SQL CI Sync command to PowerShell
Published 10 March 2016
This page shows you how to create a PowerShell script using the DLM Automation cmdlets that's equivalent to the SQL CI Sync command.
The SQL CI Sync command updates an existing database with the schema in the NuGet package created by the Build command.
This example uses the Sync command in SQL CI to update the WidgetShop database:
Command line example
sqlCI.exe Sync /package='C:\packages\WidgetShop.1.0.nupkg' /databaseServer=SQLServer2014 /databaseName=WidgetShop
Here's the same example using the DLM Automation PowerShell cmdlets:
PowerShell example
$source = "C:\packages\WidgetShop.1.0.nupkg" $target = New-DlmDatabaseConnection -ServerInstance "SQLServer2014" -Database "WidgetShop" Sync-DlmDatabaseSchema -Source $source -Target $target
In the example above:
- On line 2,
New-DlmDatabaseConnection
specifies connection details for target database. - On line 3,
Sync-DlmDatabaseSchema
updates the target database schema with the schema in the NuGet package.