在现在的应用中,一些临时脱机(Offline)应用,需要和主数据库进行定期的数据同步,采用MS Sync Framework可以快速的实现一个解决方案,而且这个框架本身有很大的扩展性,可以用于数据库(ADO.net兼容的)、文件,Web Feed等同步。
[具体的翻译在MSDN]
synchronization scope
A synchronization scope is a logical grouping of objects that must be synchronized as a unit.
knowledge
The metadata that is maintained by each participant that describes all the changes it has seen. In its simplest form, known as a watermark, a knowledge item is a clock vector that consists of pairs of replica keys and replica tick counts.
provision
After you define the synchronization scope, you provision the database to create a change-tracking and metadata management infrastructure that consists of metadata tables, triggers, and stored procedures.
http://msdn.microsoft.com/sync
http://msdn.microsoft.com/en-us/sync
官方博客 http://blogs.msdn.com/b/sync/
http://social.msdn.microsoft.com/Forums/en-US/synclab/threads
How To: Provision for Synchronization Using Snapshot Initialization
http://msdn.microsoft.com/en-us/library/gg294193(v=SQL.110).aspx
Database Synchronization
A
LTER TABLE ExampleTable ALTER COLUMN idColIDENTITY(10,1) 这个是目前的版本,现在是才CTP版本
如下是安装后其中的一个工具
C:\Program Files (x86)\Microsoft SDKs\Microsoft Sync Framework\4.0\bin
SyncSvcUtilHelper.exe
SyncSvcUtil.exe
可见常用的功能通过这些工具可以自动生成,更简化的处理的步骤。
其中例子目录iPhoneSample,是一个使用Odata协议的数据服务同步程序,很酷。
估计正式版本对开发更简化
三种同步形式
Sync Framework provides snapshot, download-only, upload-only, and bidirectional synchronization for client and server scenarios:
Ø Snapshot and download-only synchronization are typically used to store and update reference data, such as a product list, on a client. Data changes that are made at the server are downloaded to the client database during synchronization. Snapshot synchronization completely refreshes data every time that the client is synchronized. This is appropriate when you do not want to track incremental changes or the server cannot do so. Download-only synchronization downloads only the incremental changes that have occurred since the previous synchronization.
Ø Upload-only synchronization is typically used to insert data, such as a sales order, on a client. Inserts and other changes to data that are made in the client database are uploaded to the server during synchronization.
Ø Bidirectional synchronization is typically used for data, such as customer contact information, that can be updated at the client and server. Any conflicting changes must be handled during synchronization.
SDK本身有例子,其他的比较好的参考资源
Additional samples are available in the Sync Framework SDK and on Code Gallery.
http://go.microsoft.com/fwlink/?LinkId=123328
这个地址上有Orcale ,SQL Express等的例子
http://archive.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=3422
Database Sync - SQL Server and SQL Compact 2-Tier
http://archive.msdn.microsoft.com/sync/Release/ProjectReleases.aspx?ReleaseId=3761
Database Sync - Oracle and SQL Compact 2-Tier
下文我把根据SDK测试的几个例子分析一下,对这个框架有更详细的了解