Sync-DatabaseSchema fails Invalid Type Source Parameter from Invoke-DatabaseBuild
rconrad
Posts: 9 New member
I get this error
A invalid type was passed to Sync-DatabaseSchema for the Source parameter: 'C:\Code\Proto\UnitTestSandbox\UnitTestSandbox.DB\UnitTestSandbox.DB.sqlproj'
on the last line of this powershell script which I lifted from the documentation.
$errorActionPreference = "stop" # Validate the SQL Change Automation project $project = "C:\Code\Proto\UnitTestSandbox\UnitTestSandbox.DB\UnitTestSandbox.DB.sqlproj" # The SQL Change Automation project to validate, test and sync $validatedProject = Invoke-DatabaseBuild $project $validatedProject # Sync a test database $deploymentTargetConnection = New-DatabaseConnection -ServerInstance "db" -Database "AutoTestJunk220" # Update this to use the blank database created earlier Test-DatabaseConnection $deploymentTargetConnection Sync-DatabaseSchemaWhat do I need to do different?
Tagged:
Best Answers
-
Sergio R Posts: 610 Rose Gold 5It's not possible to use the SCA Project file as an input for the Sync-DatabaseSchema cmdlet
You need to add New-DatabaseBuildArtifact and then use its output as an input to the Sync-DatabaseSchema operation, for example:<div>$artifact = New-DatabaseBuildArtifact -InputObject $validatedProject -PackageId 99999 -PackageVersion 1.0.0</div><div><br></div><div><br></div><div>Sync-DatabaseSchema -Source $artifact -Target "Data Source=SQLServer;Initial Catalog=MyDB"</div>
Sergio
Product Support Engineer
Redgate Software Ltd
Please see our Help Center for detailed guides on how to use our tools -
Sergio R Posts: 610 Rose Gold 5You understood it correctly, however that only works for SQL Source Control projects. Thanks for the feedback, I will get that corrected.Sergio
Product Support Engineer
Redgate Software Ltd
Please see our Help Center for detailed guides on how to use our tools -
Sergio R Posts: 610 Rose Gold 5We have now corrected our documentationSergio
Product Support Engineer
Redgate Software Ltd
Please see our Help Center for detailed guides on how to use our tools
Answers
https://documentation.red-gate.com/sca3/tutorials/getting-started-with-the-sql-change-automation-powershell-components