| Author |
Message |
pagman
Joined: 21 Jan 2008 Posts: 5
|
Posted: Mon Jan 21, 2008 9:33 am Post subject: Version problems |
|
|
I have made schema and data compare buildtask to include in our build on Team Foundation Server.
We cannot get the schema- and data-compare running in the same build-run because the Assembly's versions for datacompare and compare are not the same.
Is it possible to get a version compatible SQL Toolkit or are there any tricks available to get the compare and datacompare running the same process? |
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
Posted: Mon Jan 21, 2008 10:19 am Post subject: |
|
|
You have to use all of the assemblies from the same directory. If you're using both SQL Compare and SQL Data Compare use the dlls from the SQL Data Compare directory only.
HTH _________________ Richard Mitchell
Project Manager
Red Gate Software Ltd |
|
| Back to top |
|
 |
pagman
Joined: 21 Jan 2008 Posts: 5
|
Posted: Mon Jan 21, 2008 11:35 am Post subject: |
|
|
When using the assemblies from the data compare folder I get the following error when I try a SQL Data compare after a schema compare
System.ArgumentException: TableMappings.Join must called with ViewTableSuperClass arguments.
RedGate.SQLDataCompare.Engine.TableMappings.Join(IDatabaseObject obj1, IDatabaseObject obj2)
RedGate.SQLDataCompare.Engine.TableMappings.Join(ViewTableSuperClass viewtable1, ViewTableSuperClass viewtable2)
Cob.Sfx.Build.Tasks.CompareDataTask.Execute()
Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound) |
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
Posted: Mon Jan 21, 2008 11:44 am Post subject: |
|
|
Can you give a fragment of your code as there is something strange going on with the called to TableMappings.Join by the looks of it. _________________ Richard Mitchell
Project Manager
Red Gate Software Ltd |
|
| Back to top |
|
 |
pagman
Joined: 21 Jan 2008 Posts: 5
|
Posted: Mon Jan 21, 2008 11:48 am Post subject: |
|
|
Method Execute has to return false if there are differences. The FQN of the tables are located in an array Tables.
| Code: |
public override bool Execute()
{
bool hasDifferences = false;
Log.LogMessage(String.Format("Data compare between {0} and {1}.", DatabaseName1, DatabaseName2));
Database db1 = new Database();
Database db2 = new Database();
db1.RegisterForDataCompare(new ConnectionProperties(ServerName1, DatabaseName1));
db2.RegisterForDataCompare(new ConnectionProperties(ServerName2, DatabaseName2));
TableMappings mappings = new TableMappings();
mappings.Options.MappingOptions = MappingOptions.Default & ~MappingOptions.IncludeTimestamps;
foreach (ITaskItem taskItem in Tables)
{
TableMapping mapping = (TableMapping)mappings.Join((ViewTableSuperClass)db1.Tables[taskItem.ItemSpec],
(ViewTableSuperClass)db2.Tables[taskItem.ItemSpec]);
mappings.Add(mapping);
}
ComparisonSession session = new ComparisonSession();
session.CompareDatabases(db1, db2, mappings);
foreach (TableDifference difference in session.TableDifferences)
{
if (HasDifferences(difference))
{
hasDifferences = true;
}
}
if (hasDifferences)
{
Log.LogError("Differences in data found.");
return false;
}
else
{
Log.LogMessage("No differences in data found.");
return true;
}
}
#endregion Public Methods
private bool HasDifferences(TableDifference tableDifference)
{
int differenceCount = 0;
foreach (Row resultsStoreRow in tableDifference.ResultsStore)
{
if (resultsStoreRow.Type != Row.RowType.Same)
{
differenceCount++;
}
}
if (differenceCount > 0)
{
Log.LogWarning("Table {0} has {1} data differences.", tableDifference.Name, differenceCount);
return true;
}
return false;
}
|
|
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
Posted: Mon Jan 21, 2008 11:58 am Post subject: |
|
|
I think this might happen if both the arguments are null. Perhaps you can put a Debug.Assert to make sure this isn't the case i.e. if the tables in your taskitem aren't in the registered databases. _________________ Richard Mitchell
Project Manager
Red Gate Software Ltd |
|
| Back to top |
|
 |
pagman
Joined: 21 Jan 2008 Posts: 5
|
Posted: Mon Jan 21, 2008 2:31 pm Post subject: |
|
|
The problem was indeed that I did not pass the fully qualified name of the tables.
It works now!
Thanks |
|
| Back to top |
|
 |
richardjm
Joined: 20 May 2005 Posts: 359 Location: Red Gate Software Ltd
|
Posted: Mon Jan 21, 2008 2:47 pm Post subject: |
|
|
Brilliant - out of interest what is your application for? _________________ Richard Mitchell
Project Manager
Red Gate Software Ltd |
|
| Back to top |
|
 |
pagman
Joined: 21 Jan 2008 Posts: 5
|
Posted: Mon Jan 21, 2008 2:53 pm Post subject: |
|
|
We build applications for a transport company. Since about a year we are using team foundation server to manage source control, builds, ...
Every build we create two databases, one reference database using VS for database professionals and a database using upgrade scripts.
With SQL Compare we check if the upgrade database is the same as the reference database, if not, the build fails.
Regards
Peter |
|
| Back to top |
|
 |
|