I'm having an issue with the Microsoft Sync Framework 2.1 and I'm hitting a stumbling block. To simplify lets say I'm syncing two tables, ConfigSet and ConfigItem, which have the following structure:
|ConfigSet |
|-----------------|
|ConfigSetID (PK) |
|ConfigItemID (FK)|
|ConfigItem |
|-----------------|
|ConfigItemID (PK)|
|ConfigItem.Data |
I'm using a filtering clause for both that's driven by ConfigSetID:
ProvisionerObject.Tables["ConfigSet"].FilterParameters.Add(new SqlParameter("@ConfigSetID", SqlDbType.UniqueIdentifier));
ProvisionerObject.Tables["ConfigSet"].FilterClause = "[side].[ConfigSetID] = @ConfigSetID"
ProvisionerObject.Tables["ConfigItem"].FilterParameters.Add(new SqlParameter("@ConfigSetID", SqlDbType.UniqueIdentifier));
ProvisionerObject.Tables["ConfigItem"].FilterClause = "[side].[ConfigItemID] in (SELECT ConfigSet.ConfigItemID FROM ConfigSet WHERE ConfigSet.ConfigSetID = @ConfigSetID)"
If I then create two ConfigItem records on the server side, 'Item1' & 'Item2', and create one ConfigSet record, 'Set1', that has a foreign key to to 'Item1', and then perform a sync it will work fine and the client will get the 'Set1' record and only 'Item1' from ConfigItem.
If I then perform an update on 'Set1' on the server so that it now points to 'Item2', the sync framework detects the changes in ConfigSet but then throws a foreign key constraint on the client saying the record 'Item2' doesn't exist.
It appears that when syncing ConfigItem that it isn't detecting any changes, because technically there have been none to ConfigItem, but the filter clause would return Item2 had this been syncing for the first time.
I understand that each table is synchronised independently, but is there a way I can force it to pick up the 'Item2' record even though there are no changes to that table? And even better (although I think I'm pushing my luck on this one with what the framework can do!) would be if it could remove 'Item1' on the client since this is technically no longer synchronised/referenced by the client.