I'm trying to do data comparison and automate database upgrade script generation by using SQL Server Database tools > SchemaComparison/DataComparison
.
Using VS command window, I am able to run
> Tools.NewDataComparison [args...]
> SQL.DataCompareExportToFile [file]
which produces .sql
file containing required inserts/updates/deletes.
Now I would like to go a step further and automate this.
I have been looking at Microsoft.VisualStudio.Data.Tools.DataCompare, Microsoft.SqlServer.Dac
and similar assemblies but haven't found any of the methods above.
Which dll
exposes these?
I have also tried to run these methods with devenv.exe
(which only starts VS and executes the arguments in command window) but was only successful at running Tools.NewDataComparison
. Is there a way to chain or reuse the context, so I can run the SQL.DataCompareExportToFile
afterwards?
I know I can use SqlPackage.exe
to export dacpac
and bacpac
, but comparison is possible only for schema. Data comparison is not. Is there a way to use bacpac
for comparison?
I would accept any solution which would allow me to compare the databases and generate the upgrade .sql
script. Either in C# or any other script.