locked
ForeignKeys specified but not built on initial sync RRS feed

  • Question

  • I've been adding foreign keys to SyncSchema.Table.ForeignKeys.Add() expecting that the CE database would have the foreign keys applied on initial sync. Checking INFORMATION_SCHEMA.TABLE_CONSTRAINTS shows that there are no user foreign key constraints applied, though there are primary key constraints.

     

    Does adding a foreign key constraint to a SyncSchema table only apply to sync, and not actually impact the CE database schema?

     

    Dave Michel

    • Moved by Hengzhe Li Friday, April 22, 2011 5:49 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Monday, January 28, 2008 7:46 PM

Answers

  •  

    yes, it should.

     

    using the schemaCreated event will be an alternative way to create the foreign key as you alreayd used.

     

    thanks

    Yunwen

    Wednesday, February 6, 2008 2:39 AM
    Moderator

All replies

  • Hi Dave,

     

    You should use the SchemaDataSet.Relations collection in the syncSchema object to specify the foreign keys. please let us know if this still won't work in you case.

     

    thanks

    Yunwen

    Friday, February 1, 2008 12:56 AM
    Moderator
  • Does that actually add the foreign keys to the CE database?

     

    I ended up building ALTER scripts in the SchemaCreated event.

     

    Tuesday, February 5, 2008 3:22 PM
  •  

    yes, it should.

     

    using the schemaCreated event will be an alternative way to create the foreign key as you alreayd used.

     

    thanks

    Yunwen

    Wednesday, February 6, 2008 2:39 AM
    Moderator
  • Yunwen - I'm trying to add SchemaDataSet.Relations but have issues - SyncSchema.Tables["table"].Columns["column"]  gives error "Can't convert SyncSchemaColumn to DataColumn"  Also won't work with Convert because IConvertable isn't implemented.

    So can you provied an example of how to make this work?
    Tuesday, February 3, 2009 7:04 PM
    • Proposed as answer by viperguynaz Wednesday, February 4, 2009 12:46 AM
    Wednesday, February 4, 2009 12:46 AM