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

对着背影说爱祢 提交于 2019-12-03 14:14:36

问题


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 changes in the Sql Server Database, We have to Deprovision the database tables. ALso after making the schema changes, we ReProvision the tables. Now in this process, the tracking tables( i.e. the Synching information) gets deleted.

I want the tracking table information to be restored after Reprovisioning. How can this be done? Is it possible to make DB changes without Deprovisioning.

e.g, the application is in Version 2.0, The synching is working fine. Now in the next version 3.0, i want to make some DB changes. SO, in the process of Deprovisioning-Provisioning, the tracking info. gets deleted. So all the tracking information from the previous version is lost. I do not want to loose the tracking info. How can i restore this tracking information from the previous version.

I believe we will have to write a custom code or trigger to store the tracking information before Deprovisioning. Could anyone suggest a suitable method OR provide some useful links regarding this issue.


回答1:


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




回答2:


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...



来源:https://stackoverflow.com/questions/13192728/making-database-schema-changes-using-microsoft-sync-framework-without-losing-any

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!