Working with Table Schemas in the Client Database
The following information is included as reference for existing applications that support offline scenarios only. For developing new applications, please see Architecture and Classes for Database Synchronization.
This topic describes several ways in which you can work with the table schemas that are created in client databases.
Client and Server Synchronization
During the initial synchronization session for a client, Sync Framework creates tables in the client database. For more information, see How to: Initialize the Client Database and Work with Table Schema. After those tables are created, some schema changes are allowed.
Sync Services does not automatically propagate schema changes from the server to the client. For information about how to handle schema changes on the server, see Deploying and Versioning Applications. The following schema changes are supported in the client database:
Drop tables. The behavior during the next synchronization depends on the value that you specified for CreationOption. If you do not want the table on the client at all, remove it from the SyncTableCollection. When you drop a table that has change tracking enabled, you also drop the system table that tracks delete operations for that table. Therefore, any delete operations since the last synchronization are not uploaded to the server.
Add new columns.
Drop columns for tables that are involved in snapshot synchronization. This change is not supported for other types of synchronization.
Add, drop, and rename indexes.
Add, drop, and rename primary keys and other constraints.
All other changes are not supported and can cause synchronization failures.
In some applications, the schema is different at the client and server. The following points summarize the behavior for a table and the ADO.NET dataset that Sync Services uses to update that table at the client:
If the dataset contains Column1 and Column2, and the table contains Column1, Column2, and Column3: The values in Column1 and Column2 are applied, and Column3 is set to its default value or NULL if the column does not have a default.
If the dataset contains Column1, Column2, and Column3, and the table contains Column1 and Column2: The values in Column1 and Column2 are applied, and Column3 is ignored.
If the dataset contains Column1, Column2, and Column3, and the table contains Column1 and Column2, and Column4: The values in Column1 and Column2 are applied; Column3 is set to its default value or NULL if the column does not have a default; and Column4 is ignored.