How can we help you today? How can we help you today?

Sync-DatabaseSchema fails Invalid Type Source Parameter from Invoke-DatabaseBuild

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-DatabaseSchema
What do I need to do different?
Rich Conrad
0

Comments

4 comments

  • Sergio R
    It'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 R
    0
  • rconrad
    Yes, that works.  Thanks.  Am I misunderstanding the documentation on the getting started page?  The code snippet for "Syncing to a test database" does not identify the source of $validatedProject, but the only other reference is the snippet in "Validating the SQL Change Automation project" which is set from Invoke-DatabaseBuild.

    https://documentation.red-gate.com/sca3/tutorials/getting-started-with-the-sql-change-automation-powershell-components
    rconrad
    0
  • Sergio R
    You understood it correctly, however that only works for SQL Source Control projects. Thanks for the feedback, I will get that corrected.
    Sergio R
    0
  • Sergio R
    We have now corrected our documentation
    Sergio R
    0

Add comment

Please sign in to leave a comment.