Friday, April 15, 2011

Sharing learnings I had while working on Microsoft Sync Framework 4.0 (CTP)

Recently, I started using Microsoft Sync Framework 4.0 (CTP). I faced many issues in the begining when I was configurating it. There were some basic doubts in my mind about what it can do and what it can not do. Basically, what should I expect from it.

Following are list of questions (FAQs) I had and answers I found from Sync documentation, official forums and blogs:
  • Does Microsoft Sync Framework 4.0 need to talk to SQL Server directly? Is it possible if I introduce SOA layer between Microsoft Sync Framework 4.0 and SQL Server?
yes it needs to. it needs to ask the database server what to sync. if you dont want to use the built-in providers, you can write your own, but then, Sync Fx will still need to talk to your provider and your provider to SQL.
the WCF-based sync service already provides a good abstraction to the back-end database such that the client need only know the service and not where and what the database is.
  • How can Android talk to Microsoft Sync framework?
No, we just didnt have the time/expertise in the team to generate an Android sample. I think there are some c# to Java source code converters that you may employ to convert the Wm6.5 sample. This should give you a good starting point for the Android sample.
if you are looking for pure Android code I can´t help you but for MonoDroid there is a nice solution which already supports the sync framework 4.0 CTP. I am currently evaluating this nice oodb called siaqodb. For more informations goto
  • What work does 'SyncSvcUtil.exe' utility do to instrument the database?
SyncSvcUtil is just a utility to provision/deprovision scopes, generate code for WCF-based sync service, isolated store and client entities.
The only changes that we do to the database when you use SyncSvcUtil is to use the SqlSyncScopeProvisioning/SqlSyncScopeDeProvisioning API's from SyncFx 2.1 to provision/deprovision the database based on the request.
This means that we create insert/update/delete triggers, tracking tables and few stored procedures per table for change tracking/enumeration/change application purposes. This is exactly similar to what you would have done, had you used SyncFx 2.1 to manually provision the database.
  • How can I disable this redirection to $syncscopes???
A service that is generated by SyncFx 4.0 CTP only uses OData as the wire format since it is a widely recognized format for representation od data. The SyncFx service does not perform OData operations as documented in instead it only knows how to upload and download incremental changes. To make this possible, we made some additions to the OData format to support sync specific constructs like knowledge, tombstones etc. The redirection to $syncscopes is our way of letting you discover what scopes are available for sync from the service. Internally, the service uses Sync Framework 2.1 database providers.
  • Issue faced: Server error in fetching remote contacts: HTTP/1.1 500 Internal Server Error
Following steps fixed the issue for me:
I had installed 32 bit version of Sync Framework 2.1 SDK. Installation was successful for me so I thought things are working fine until I got HTTP 500 error. 500 error appears usually if something is wrong on server side.
I removed total Microsoft Sync Framework 4.0 (CTP) and installed freshly as mentioned in download instructions for 64 bit installation. That worked for me. See following link for more information regarding the issue.
If server side setup is proper then make sure IIS application pool's Process Model is set to LocalSystem. This will not be that secure but check it to make sure things are working fine on IIS side.
If that is done and still you are facing issue then make sure you have done as follows:
1. Launch SQL Server Management Studio.
2. Expand Security, right-click Logins, and then click New Login.
3. Enter NT AUTHORITY\NETWORK SERVICE for the Login name, switch to the User Mapping tab.
4. Select listdb from the database list and select db_owner from the role list, and then click OK.

1 comment:

  1. Now They release Microsoft Sync Framework 4.0 (CTP) as Open source SDK, Sync Toolkit based on Microsoft Sync Framework 4.0 (CTP). It has the support for iPhone, and HTML 5. I found some one also created an Android sample using this as well.