在现在的应用中，一些临时脱机(Offline)应用，需要和主数据库进行定期的数据同步，采用MS Sync Framework可以快速的实现一个解决方案，而且这个框架本身有很大的扩展性，可以用于数据库(ADO.net兼容的)、文件，Web Feed等同步。
A synchronization scope is a logical grouping of objects that must be synchronized as a unit.
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.
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.
How To: Provision for Synchronization Using Snapshot Initialization
Sync Framework Tips and Troubleshooting
- Use snapshot initialization to create and initialize multiple SQL Server Compact databases in your synchronization community. Snapshot initialization offers much faster performance for setting up multiple SQL Server Compact databases than provisioning each one individually. And the API is simple, too! Here's an article that tell you how to do this: http://msdn.microsoft.com/en-us/library/gg294193(v=SQL.110).aspx.
- Use backup and restore (with post-restore fixup) to create and initialize multiple large SQL Server databases in your synchronization community. If you are setting up a synchronization community that contains copies of a large SQL Server database, performance will be better if you use backup and restore to create the database copies instead of an initial synchronization. Here's an article that tells you how to do this: http://msdn.microsoft.com/en-us/library/ee617375(v=SQL.110).aspx.
- Don't use TRUNCATE TABLE to modify a table that is synchronized. This is because, while TRUNCATE TABLE is in effect a DELETE statement, it does not activate the trigger used to update the change tracking metadata, so the deletion is invisible to Sync Framework and will not be sent to other replicas.
- To find a list of the scopes that are currently provisioned in a database, query the scope_info table. The scope_info table contains information about each scope, including the scope name.
- When a table in a SQL Server Compact database is initialized through synchronization, the seed and increment of its identity columns are always set to 0 and 1, respectively, regardless of how they are set on the server database. If you need to insert rows locally in the client database you must first set the identity seed and increment to appropriate values or manually specify the identity column value, otherwise new rows will have duplicate identity values and row insertion will fail. The identity seed and increment can be set with the following query, which sets the seed value to 10 and the increment to 1:
ALTER TABLE ExampleTable ALTER COLUMN idColIDENTITY(10,1)
Sync Framework 4.0
C:\Program Files (x86)\Microsoft SDKs\Microsoft Sync Framework\4.0\bin
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.
Additional samples are available in the Sync Framework SDK and on Code Gallery.
这个地址上有Orcale ,SQL Express等的例子
Database Sync - SQL Server and SQL Compact 2-Tier
Database Sync - Oracle and SQL Compact 2-Tier