数量并框架MS Sync Framework [术语、例子、参考资料、Tips]

每当今之采取中,一些即脱机(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

Sync Framework Tips and Troubleshooting

http://social.technet.microsoft.com/wiki/contents/articles/sync-framework-tips-and-troubleshooting.aspx

Database Synchronization

  • 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

这是当下底版本,现在是才CTP版本

如下是安后里的一个器

C:\Program Files (x86)\Microsoft SDKs\Microsoft Sync
Framework\4.0\bin

SyncSvcUtilHelper.exe

SyncSvcUtil.exe

图片 1

看得出常用之效力通过这些工具得以自动生成,更简化的处理的步调。

其中例子目录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测试的几乎只例子分析一下,对这框架来更详实的问询

相关文章