4

I'm very new to asp.net with database synchronization. Currently I'm implementing a project that required Server (SQL Server 2010) <> C# Client (SQLite) bidirenctional database synchronization using change tracking. I had go through most of the tutorial/example discussed in forums and Stack Overflow:

http://dotnetvisio.blogspot.com/2013/07/microsoft-change-tracking-sql-server.html

Syncing SQL Server 2008 Databases over HTTP using WCF & Sync Framework

http://msdn.microsoft.com/en-us/library/cc305322.aspx

http://technet.microsoft.com/en-us/library/cc280358(v=sql.105).aspx Etc...

However, I couldn't get any idea on how to implement change tracking database synchronization in between:

[SQL Sever Database with Change Tracking enable] <> [WCF Service] <> [WPF Client] <> [SQLite Local Database]

So my question is how to connect and establish the connection for synchronization with local database? A step-by-step tutorial is much appreciated. Thanks.

Community
  • 1
  • 1
BlackHat
  • 147
  • 2
  • 3
  • 13
  • Just to be clear you are connecting two databases together directly with Sync Framework, and not going through a third party right? Your 'diagram' model is throwing me for a loop – JNYRanger Jan 22 '14 at 03:47
  • Yes, database will be connected via sync framework. Sorry for confusing. – BlackHat Jan 22 '14 at 03:55
  • No prob, check out my answer. Just used this for a project a few months back as my first experience with the Sync Framework. It's far easier to use than some of those articles make it out. – JNYRanger Jan 22 '14 at 03:55
  • If you use SQL Server Compact on the client, it is almost trivial to implement, but if you must use SQLite then you are going to experience pain. You'll want to intercept all calls to the DB to track the Knowledge Meta Data. – Timothy Walters Jan 24 '14 at 03:34
  • I found an article that talks about how to implement it in SQLite (hint: manually tracking "dirty" and "tombstone" records to tell the server about them): http://jtabadero.wordpress.com/2013/01/09/synchronizing-winrtsqlite-using-sync-framework-toolkit/ – Timothy Walters Jan 24 '14 at 03:39
  • @TimothyWalters Thx for your info. However, database provisioning is banned from this project development as stated. And yes, i need it to be done by using SQLite as client database. – BlackHat Jan 27 '14 at 12:19

1 Answers1

2

Assuming you are using the Sync Framework to sync two databases together directly you don't need to manually implement the change-tracking components in most situations with SQL Server and/or SQL Server Compact. The easiest way to do this is by writing a helper application that handles the scoping and provisioning of the databases for you. This will have the Sync Framework automatically create all of the change-tracking objects (Tables/Functions/StoredProcs) necessary for Sync Framework to work properly. Check out this article form MSDN: Walkthrough: Defining Scope and Provisioning

If you can't use provisioning you have some work ahead of you since you will need to write all of your own providers. It's unfortunately not as easy of a task as you'd expect and there isn't much info out there. Here are a few articles to get you started:

http://www.8bit.rs/blog/2009/05/debugging-sql-express-client-sync-provider/

MS's Response that Change Tracking & The Sync Framework are not Directly Compatible

Sync Framework Metadata Services -- This is the info on what you need to build your own providers

JNYRanger
  • 6,829
  • 12
  • 53
  • 81
  • I had go through your tutorial previously as well. However, forget to mention that provision is banned from this project development. Only change tracking are allowed. – BlackHat Jan 22 '14 at 03:59
  • Well then, that changes things a bit now! You can use use the built in change tracking, but you need to write your own knowledge providers. Hold on I have an article about this. – JNYRanger Jan 22 '14 at 04:02
  • Thanks for your information. I do understand that this isn't an easy task for me and that's why I'm here asking for help. :) – BlackHat Jan 22 '14 at 04:30