Database Sync:SQL Server and SQL Express N-Tier with WCF

Shows how to use the Sync Framework 2.1 database providers to configure and execute synchronization between a SQL Server database and one or more SQL Server Express databases. This sample demonstrates syncing with a central server as well as between two clients.

C# (91.1 KB)
 
 
 
 
 
(10)
9,528 times
Add to favorites
3/14/2011
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • When i try to synchronise the following error occured
    1 Posts | Last post June 24, 2013
    • "The current operation could not be completed because the database is not provisioned for sync or you not have permissions to the sync configuration tables."
  • Is It Possible to Use Sync Framework with VS LightSwitch 2012
    1 Posts | Last post January 22, 2013
    • Hi Gary
      
      I am developing an application using Visual Studio LightSwitch. In there I have an requirement to sync local SQL Express Database to Remote SQL Server or SQL Azure Database.
      
      Is this possible by using Microsoft Sync Framework? If yes then how?
      
      If you can develop a sample lightswitch application with Microsoft Sync Framework Integration then I will be really grateful to you.
      
      Thank You
      Rashmi 
  • syncing between two clients
    1 Posts | Last post July 23, 2012
    • I have the sample working in VS2010 but the peer databases are being created on the main server. How can I create and sync using clients (i.e. peer-to-peer).
      
      Thanks
  • Microsoft.Synchronization.Data 2.0
    3 Posts | Last post June 06, 2012
    • Just a minor comment and I know it's a simple thing to do myself however you should provide a Visual Studio 2010 version of the solution.
    • Hi Jeff
      
      Did you get the sample working in visual studio 2010? Could you please send me tips on how to get the sample working?
      
      Thank you
      Attie
    • I was able to get it to work in Visual Studio 2010 just fine with a few modifications. 
      
      As soon as the port from 08 to 10 is finished you will need to do a few things. First, make sure you have the latest SYNC services framework,SDK and Redistributables installed. Install the SQL files it comes with. Next I had to change each of the projects to .Net 4.0 and X64. You may not need to change to x64 but you will be required to update to 4.0 or 3.5(havent tested 3.5) at the least. 
      
      WHen you port it leaves it in 2.0 framework which causes errors. If you don't have the latest SYNC framework you will also get errors, about 6 of them including the .EXE can't find error due to the WebSyncContract project not building. 
      
      You will then need to delete the references (if it doesn't build and you get RelationalSyncProvider,SqlSyncProvider or other errors and re-add those references making sure you reference the correct DLL's. I went into programs and deleted all previous versions of the sync framework due to issues of it still some how referencing 1.0 sync service. You should be able to build now. 
      
      It's a pretty easy port from 08 to 10 with the only major errors being descrivbed above with framework versions. Cheers
  • Convert WCF as reference Service
    1 Posts | Last post March 15, 2012
    • Hi,
      I have added wcf as reference on my project and everything is fine. when i converted it as service reference ( removed the proxy classes in the code because i used VS to auto generate the proxy class) 
      I'm looking for a way to get the wcf sqlsyncProvider :
      have create:
      [DataContract]
          [KnownType(typeof(KnowledgeSyncProvider))]
          public class GetSqlSyncProvider
          {
              [DataMember]
              public object PeerProvider;
          }
      Client Side:
       
      GetSqlSyncProvider prov = webSyncService.GetSyncProvider(SyncUtils.ScopeName, SyncUtils.destConnStr);
      SyncOperationStatistics stats = synchronizationHelper.SynchronizeProviders(srcProvider, prov);
      
      I have got serialization exception:
      
      System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.
      
      any suggestion? thanx
  • WCF test client cannot find metadata
    3 Posts | Last post January 28, 2012
    • I've tried this sample code and it works. The db peer are synchrozined.
      
      but when I try to test the service with WCF test client, i receive the following error :
      
      
      http://localhost:8000/WebSyncContract/SqlWebSyncService/mex
      
      Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.
      
      c:\Users\stephane\AppData\Local\Temp\Test Client Projects\10.0\577cd186-2140-466f-a121-7d31ef3ea35d\Client.cs(1277,13) : error CS0246: The type or namespace name 'schema' could not be found (are you missing a using directive or an assembly reference?)
      c:\Users\stephane\AppData\Local\Temp\Test Client Projects\10.0\577cd186-2140-466f-a121-7d31ef3ea35d\Client.cs(1283,12) : error CS0246: The type or namespace name 'schema' could not be found (are you missing a using directive or an assembly reference?)
      
      Any idea ?
    • thanks to vishalvatsal post in another forum, I removed the line 
      "[ServiceKnownType(typeof(SyncIdFormatGroup))]"
      
      in namespace WebSyncContract
      
      and it solved my problem
      
      
    • Hmmm. But then have you gone back and tried to run without debugging? You may find you need that line else you'll get an"System.ServiceModel.CommunicationException: There was an error while trying to serialize parameter http://tempuri.org/:sourceChanges" exception thrown. For some reason though, the app. still seemed to work for me in debug mode even though WCF Test Client said it couldn't add the service. 
  • Unable to build
    7 Posts | Last post January 25, 2012
    • In this app, interfaces are there... but where is the service file; it has to be added to the service reference or not? Do help me... Thanx in advance!
    • I am getting the following error on building the app...
      
      Error	7	Could not load referenced assembly "D:\Giftson\Sample\Downloads\Database SyncSQL Server and SQL Express N-Tier with WCF\C#\WebSyncContract\WebSyncContract\bin\Debug\WebSyncContract.exe".  Caught a FileNotFoundException saying "Could not load file or assembly 'D:\Giftson\Sample\Downloads\Database SyncSQL Server and SQL Express N-Tier with WCF\C#\WebSyncContract\WebSyncContract\bin\Debug\WebSyncContract.exe' or one of its dependencies. The system cannot find the file specified.".	D:\Giftson\Sample\Downloads\Database SyncSQL Server and SQL Express N-Tier with WCF\C#\ResGen	WebSharingAppDemo-SqlProviderEndToEnd
      
    • In your testing project, WebSyncContract must be added as reference
    • Hi spillsome,
      Thanx for ur reply. Actually, after i download this app, i donot find WebSyncContract.exe file inside the debug folder to add the reference... What i have to do? can u mail that file?
    • You need to build the WebSyncContract project. It is the Web service.
    • fine... I removed and added the references - Microsoft.Synchronization. It is executing and got the output.
    • I had this issue, I have a 64bits machine. I selected the CommonUtils project right click>properties>Build> then change the platform to 64 bit
      
      Then in the WebSynContract project the same process and it works.
      
      Remember to configure the database with the sample scrits and change the sql server instance if it is different of your machine name.
      
      Hope helps
  • Cannot run the code
    2 Posts | Last post November 24, 2011
    • I haven't changed much of this code. The service's running in http://localhost:8000/RelationalSyncContract/SqlSyncService/
      I can see peer1's tables but when i try to synchronize with another database, i get the following error:
      
      There was no endpoint listening at http://localhost:8080/RelationalSyncContract/SqlSyncService/ that could accept the message. This is often caused by an incorrect address or SOAP action
      
      in line 57 of RelationalProviderProxy.cs
    • I got the same problem with I try to sync a table with large amount of data (70k records). It's OK when the amount of data is small (in hundreds)
  • WCF test client cannot find metadata
    1 Posts | Last post October 24, 2011
    • I have tried this sample and getting exactly same error as mentioned by spillsome below.
      Can someone/creator of the sample please provide some solution?
      
      
  • Just Server/Client
    2 Posts | Last post August 10, 2011
    • Has anyone stripped out the Peer to Peer side of WCF sync and just got a sample showing server/client syncing over WCF?
    • Hi HarjS, I am also trying to find exactly what you are after. Did you get any break through with it?
1 - 10 of 12 Items