BKStart a conversation ↗

Microsoft Synchronization Services, WCF OData, SQL Azure, WPF, iPhone

Part 1 – Setting up your database

I did some work with an interesting piece of tech lately, Microsoft Synchronization Services 4.0 CTP. This post aims to give an overview of where to start, but firstly, let me describe how all this plugs together and what it buys me.

Overview

The OData + Sync protocol uses the OData format for the data payload that can be consumed by clients that are running on any platform. Clients and the service use the protocol to perform synchronization, where a full synchronization is performed the first time and incremental synchronization is performed subsequent times. The protocol is designed with the goal to make it easy to implement the client-side of the protocol, and most (if not all) of the synchronization logic will be running on the service side. OData + Sync is intended to be used to enable synchronization for a variety of sources including, but not limited to, relational databases and file systems.

Server

The CTP release includes server components that make it easy for you to build a sync Web service that exposes data to be synchronized via the OData + Sync protocol. For example, you can easily expose data in a SQL Server database or a SQL Azure database via a WCF sync endpoint using these server components. In our case our server is sitting in the Azure Cloud providing an OData endpoint, the data is also hosted in the Cloud in SQL Azure.

Clients

We have 3 clients, (well 4 actually but our Silverlight version has lagged behind and is not yet publicly available).

  1. WP7 – Local data stored in Isolated Storage, DataVisualizationToolkit for charting, SL3
  2. iPhone – Connecting directly to the server via OData/JSON
  3. ASP.MVC Ajax – A powerful web interface written using MVC3 and jQuery
  4. Silverlight – Initially used RIA Services to access the server but synchronization model is nearly identical to the WP7 SL3 approach with isolated storage now.

How to create the server.

  1. Create your database schema in SSMS (SQL Server Management Studio)
  2. Now that your database has been created you’ll need to provision it, think of this much in the same way that you would provision an existing SQL Server database for asp membership tables and stored procedures. The synchronization framework will provide you with a tool called SyncSvcUtilHelper.exe. This basically is a GUI for the command line version.

Before provisioning you’ll need to create a Sync configuration, so choose option one, select a filename in step 1 and select your database in step 2.

Select the list of tables that you are interested in syncing.

That’s pretty much it. Now you’ll need to choose option 2 to provision the database.
Select the configuration file you created as part of step 1 and choose the provisioning option.

That’s all that’s involved, your Database is now ready to be synchronized, of course there are some considerations, unique id’s etc, but you’ll find all this in the documentation.

My next post will cover creating the WCF service for exposing the database, after that I’ll run through creating the clients.