0

I am using the VS2008 Local Data Cache tool to synchronize a SqlServer 2008 Db with a local SQL CE 3.5. At the server I have a table with a PK with datatype uniqueIdentifier and defaultvalue newID(). Upon initial synchronization through the Local Data Cache the DB it creates does not copy the default value for this column (as described here: http://msdn.microsoft.com/en-us/library/bb726037%28v=SQL.105%29.aspx, See "..the following constraints are not copied to the client: FOREIGN KEY constraints, UNIQUE constraints, and DEFAULT constraints...")

I have found a similar question here: MS Sync Framework: Table schema not copied to local db.

But when I tried to implement the solution, I found that the CreatingSchema event for the clientSyncProvider of my Local Data Cache partial class does not fire.

How come? How do I change the schema for a local Data Cache?

Thanks for any ideas you can come up with.

Community
  • 1
  • 1
Winks
  • 580
  • 1
  • 7
  • 17
  • I have made schema changes in the code-behind of the partial public class `LocalDataCacheClientSyncProvider` and the event `CreatingSchema`. Here's what I've written to change the `defaultvalue` of a PK GUID to `newid()`: `If e.Table.TableName = "Users" Then` `If (e.Schema.Tables("Users").Columns("UserID").DataType Is GetType(System.Guid)) Then` `e.Schema.Tables("Users").Columns("UserID").DefaultValue = "NEWID()"` `End If` `End If` – Winks Jul 03 '11 at 14:40

1 Answers1

0

what is the TableCreation option settings for your client database? if the SDF and the initial schema has been created by the Local Database Cache wizard, then subsequent syncs will no longer create the schema not unless you specify via the TableCreation option that the existing tables be dropped and replaced with a new schema.

JuneT
  • 7,840
  • 2
  • 15
  • 14