locked
Adding new columns to sync when using Local Database Cache RRS feed

  • Question

  • I am using a local database cache to  sync my Sql Server instance to a Sql Ce instance. I have added identical columns to both databases. I tried running the custom tool, but it doesn't seem to pick up the new columns. How do I get those new columns to sync?
    Monday, November 15, 2010 9:13 PM

Answers

  • i thought you said you've added the column already to both databases? so the code generator will pick up this new columns. if you haven't manually added the column, check you're table creation option. most likely your TableCreationOption is set to use the existing table.
    • Marked as answer by Joshua Chan Thursday, November 18, 2010 3:52 PM
    Thursday, November 18, 2010 12:30 AM

All replies

  • i'm assuming custom tool you mean the local database cache wizard, try removing the table in the wizard and adding it back. you may also add the column manually in the wizard generated sql codes.
    Wednesday, November 17, 2010 9:30 AM
  • Removing and re-adding the table doesn't seem to work. As for the command building code in the designer code behind, the new columns are listed. It still does not create them in my client db.
    Wednesday, November 17, 2010 3:57 PM
  • Ok, it seems like the best method to get columns added is to delete the table, delete the sync tables, run the wizard, recreate key constraints/relationships.
    Wednesday, November 17, 2010 4:02 PM
  • i thought you said you've added the column already to both databases? so the code generator will pick up this new columns. if you haven't manually added the column, check you're table creation option. most likely your TableCreationOption is set to use the existing table.
    • Marked as answer by Joshua Chan Thursday, November 18, 2010 3:52 PM
    Thursday, November 18, 2010 12:30 AM
  • Ok, I see. It does work.

    A couple of things:

    The first time I tried to add columns I did add the columns identically to both databases. However, my client-side changes were not making it back up to the server. The reason is because I had injected the code specifying the SyncDirection as Bidirectional directly into the designer generated code. When I ran the wizard, my code was lost. Since then I had moved that code to a separate file, so I had a false negative.

    When adding the columns to my database in my DataAccessLayer project, a new version of the database gets copied into the bin directory of my start up project. Any test work done against that db is lost with the new deploy unless it was synced and uploaded to the server. For some reason, when I try to sync on the new client db and pull down the data from the server, it doesn't work. I assumed the change tracking is preventing it, so I had to update a column in each table and set the value back to itself. I guess that's a separate issue. Is there not a better way to force a full sync?

    Thursday, November 18, 2010 3:52 PM
  • So, as I mentioned previously, changing the columns in the client db deploys a new client db to my debug directory, and for some reason the snapshot initialization when running the wizard doesn't work. Maybe I ran the wizard before I added my new columns. I'm not sure.

    I force the sync by updating all of my tables, setting the a column's value back to itself.

    I am using Entity Framework, and I have a join table. This table has only two columns, a primary key for each table it is joining.

    That join table is the only table that does not sync. I tried setting those keys back to themselves... no joy.

     

     

    I am splitting this issue off to another post: http://social.microsoft.com/Forums/en-US/syncdevdiscussions/thread/d8e6b5a5-7742-414e-a806-223dcec4aae8

     

    Thursday, November 18, 2010 4:45 PM
  • I had missed a table, and that table is used in conjunction with another table to form and Entity. The entity would not load because of that.

    Rar!

    There has got to be a better way to do a full sync.

    Thursday, November 18, 2010 5:24 PM
  • fyi, if you're using the Local Database Cache Wizard, there are other things you need to tweak other than changing the SyncDirection to enable bidirectional synchronization.

    check Walkthrough: Extending the Local Database Cache to Support Bidirectional Synchronization in the documentation under Offline-Only scenarios.

    btw, any particular reason why you're using the wizard and the offline providers rather than the peer-to-peer/collaboration providers?

    Friday, November 19, 2010 12:47 AM
  • Thanks for the tip. I'll definitely give it a look.

    I have no reason at all, because I don't know what options are out there, how to deterimine the right one for me, and how to implement that solution. I'm still trying to understand Sync Framework. I have several large hurdles left to cover. I have definitely tried to read and understand every piece of documentation that is out there. I am just not sure which of it applies to me.

    I don't know if it makes a difference, but I don't think have a peer-to-peer/collaboration scenario. What qualifies as a peer-to-peer/collaboration scenario?

    In my situation, I want users to choose the records they want to pull down, modify those records, and then choose which records they want to upload. Is that collaborative? It seems like it might be.

    Friday, November 19, 2010 2:23 PM
  • neither the offline provider nor the collaboration provider allows selectively choosing which rows to synchronize. the offline and peer-to-peer providers differ in the way they track changes, provisioning and keeping track of what changes has been applied.

    i suggest you go thru the tutorials/walkthroughs in the documentation so you get a feel of the difference between the two.

    what you're trying to do can be achieved in either providers via their filter support.

    Friday, November 19, 2010 2:40 PM
  • I started reading http://msdn.microsoft.com/en-us/sync/bb840037.aspx

    I noted that the Sync Framework was built with similarity to what is offered in ADO .Net. I don't really know ADO .Net that well (I've been doing .Net for 3 years). Do you think I need to review material on ADO .Net to get a better grasp on Sync Framework?

    Monday, November 22, 2010 2:15 PM
  • not necessarily. Not unless you want to manipulate the change dataset. Sync Fx handles the change detection, change selection and change application for you out of the box.

     

    Monday, November 22, 2010 3:13 PM