Making database schema changes using Microsoft Sync framework without losing any tracking table data

前端 未结 2 1908
死守一世寂寞
死守一世寂寞 2021-02-11 07:43

I am using Microsoft Synch Service Framework 4.0 for synching Sql server Database tables with SqlLite Database on the Ipad side.

Before making any Database schema change

相关标签:
2条回答
  • 2021-02-11 08:20

    Lets say I have one table "User" that I want to synch. A tracking table will be created "User_tracking" and some synch information will be present in it after synching.

    WHen I make any DB changes, this Tracking table "User_tracking" will be deleted AND the tracking info. will be lost during the Deprovisioning- Provisioning process.

    My workaround: Before Deprovisioning, I will write a script to copy all the "User_tracking" data into another temporary table "User_tracking_1". so all the existing tracking info will be stored in "User_tracking_1". WHen I reprovision the table, a new trackin table "User_Tracking" will be created. After Reprovisioning, I will copy the data from table "User_tracking_1" to "User_Tracking" and then delete the contents from table "User_Tracking_1". UserTracking info will be restored.

    Is this the right approach...

    0 讨论(0)
  • 2021-02-11 08:24

    the provisioning process should automatically populate the tracking table for you. you don't have to copy and reload them yourself.

    now if you think the tracking table is where the framework stores what was previously synched, the answer is no.

    the tracking table simply stores what was inserted/updated/deleted. it's used for change enumeration. the information on what was previously synched is stored in the scope_info table.

    when you deprovision, you wipe out this sync metadata. when you synch, its like the two replicas has never synched before. thus you will encounter conflicts as the framework tries to apply rows that already exists on the destination.

    you can find information here on how to "hack" the sync fx created objects to effect some types of schema changes.

    Modifying Sync Framework Scope Definition – Part 1 – Introduction

    Modifying Sync Framework Scope Definition – Part 2 – Workarounds

    Modifying Sync Framework Scope Definition – Part 3 – Workarounds – Adding/Removing Columns

    Modifying Sync Framework Scope Definition – Part 4 – Workarounds – Adding a Table to an existing scope

    0 讨论(0)
提交回复
热议问题