I’ve recently started playing around with the Microsoft Sync Framework (MSF) in my downtime…which hasn’t been much lately due to a new role at work that has me learning a whole new skill set. But in the little bit of time I have had I have found the MSF to be interesting enough to be worth the time. Here are just a few things I’ve run across that may help you get started with MSF if you are new to it as well. (I’ve been primarily focused on Sync Services for ADO.NET)
- Get the v1.0 of the framework here: Microsoft Sync Framework v1.0
o V2.0 is in the works, and has a CTP release if you are interested in the bleeding edge: Microsoft Sync Framework v2.0 CTP1
o Help and Documentation is always nice if you are into that type of thing: Microsoft Sync Framework Documentation
- There are some upgrades/patches in VS 2008 SP1 that enable you to cache/sync a wider range of schemas. So if you are using VS 2008 I suggest installing the service pack. Even if you have no desire to use MSF, I still suggest SP1 for VS 2008; there are a lot of goodies in it.
- You cannot sync tables if that table…
o Does not have a primary key
o Has a name longer than 118 characters
o Contains a data type not supported by SQL Compact 3.5
- MSF is very “smart” and does quite a lot of the heavy lifting for you, but be cautious of some actions it is taking on your behalf. This is especially true since it will be modifying your SQL Server data source if you are using sync for ADO.NET. My previous blog is about an instance where I ran into an issue where MSF created an update trigger on a table that already had one.
- By default synchronization only occurs one way. Server to client. To enable bidirectional synchronization or any other type of sync the following line of code will be helpful. Just remember to replace [TableName] with the actual table you are syncing. Place it in the OnInitialized() method, in the code file behind your sync file.
o this.[TableName].SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional;
- There are a couple ways to setup syncing. Adding a Local Database item and a Local Database Cache item. Both achieve roughly the same results but you’ll have a much easier time if you use the Local Database Cache item.
- For learning purposes I would recommend Northwind over AdventureWorks if you are going to go the route of using a sample database. AdventureWorks is full of complex data types, triggers and relationships that makes learning MSF more challenging than it needs to be. On the flip side, once you got the hang of MSF it is good to give it a run by the AdventureWorks database to learn some of its limitations.

Leave a comment
Comments feed for this article