Why aren't FK constraints applied to sql CE an sql Express client? RRS feed

  • Question

  • Hi, everyboday!

    I am developing the sync app which will sync Sql CE and Sql Express clients with Sql Server 2008, but I have a problem in provisioning.

    Data sync works well, but on client FK setup and foreign key constraints are not applied from server.

    Clients provision based on the scope from server.

    Here is my provisioning script on server.

    , (System.Data.SqlClient.SqlConnection)provider.Connection));
    tb_name = "dbo.Users" ;
    DbSyncTableDescription dtd = SqlSyncDescriptionBuilder.GetDescriptionForTable(tb_name, (System.Data.SqlClient.SqlConnection)provider.Connection);
    dtd.Constraints.Add(new DbSyncForeignKeyConstraint("FK_Users_Roles" , "dbo.Roles" , "dbo.Users" , "RoleId" , "RoleId" ));

    //note that it is important to call this after the tables have been added to the scope

    //Getting again to confirm the FK constraints....
    DbSyncScopeDescription dsd = SqlSyncDescriptionBuilder.GetDescriptionForScope(WandSyncServiceUtils.getScopeName(), (SqlConnection)provider.Connection);

    At the last statement, I get the scope to confirm the apply result.

    But dsd.Tables[1].Constraints.Count = 0, which means that constraints is not created.

    I don't know what the problem is really.

    In server schema, RoleId of Users table is indicated as "FK, uniqueidentifier, null" exactly.


    Please give me your opinion. Would you like to share your code which works well?


    Best Regards



    Friday, January 7, 2011 2:45 AM