locked
Provisioning CE database from SqlServer database renames primary key indexes. RRS feed

  • Question

  • I'm using Sync Framework 2.0 to provision a CE database from an Sql Server 2008 Express database. In my server database, I have Primary Keys with a naming convention of tablename_PK. Some are single columns and some are compound. I generated them in the Express database like this:

     

    alter table "MyTable" add constraint "MyTable_PK" primary key ("AElementId", "BElementId")   

    The I do create and provision my CE database:

     

                 // Create the database file

     

                SqlCeEngine engine = new SqlCeEngine(connectionString);

                engine.CreateDatabase();

     

                // Set up the provider

     

                SqlCeSyncProvider ceProvider = new SqlCeSyncProvider();

                ceProvider.ScopeName = ServerDb.ScopeName;

                ceProvider.Connection = new SqlCeConnection("Data Source=" + connectionString);

     


                // Do the provisioning

     

                SqlCeSyncScopeProvisioning ceConfig = new SqlCeSyncScopeProvisioning();

                if (!ceConfig.ScopeExists(serverProvider.ScopeName, ceProvider.Connection))

                {

                    DbSyncScopeDescription scopeDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope( serverProvider.ScopeName, serverConnection);

                    ceConfig.PopulateFromScopeDescription(scopeDesc);

                    ceConfig.Apply(ceProvider.Connection);

                }

     

    After provisioning, my sample table in the new CE database has and primary key index called PK_MyTable on the correct columns. The problem is that instead of being called "MyTable_PK", it is not "PK_MyTable".

    My question is, how can I alter this behavior to keep the name I have in my server database?

    OR

    ... to set a default convention of tablename_PK instead of PK_tablename? 

    Either solution would work for me, but I prefer the first solution.

     

     


     

    Wednesday, July 7, 2010 6:59 PM

Answers

  • afaik, you can't "PK_tablename" is a hardcoded naming convention in the provisioning.

     

    • Marked as answer by wwaters Wednesday, July 7, 2010 10:58 PM
    Wednesday, July 7, 2010 9:46 PM