Answered by:
ForeignKeys specified but not built on initial sync

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 AMModerator
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 AMModerator -
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 AMModerator -
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 -
answered my own question - bump to post - http://social.msdn.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/10fc99c5-89c2-4db5-83e5-1a2a2757e14e
- Proposed as answer by viperguynaz Wednesday, February 4, 2009 12:46 AM
Wednesday, February 4, 2009 12:46 AM