Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change client schema during provisioning?
    text
    copied!<p>I'm rushing (never a good thing) to get Sync Framework up and running for a "offline support" deadline on my project. We have a SQL Express 2008 instance on our server and then will deploy SQLCE to the clients. Clients will only sync with server, no peer-to-peer.</p> <p>So far I have the following working:</p> <ol> <li>Server schema setup</li> <li>Scope created and tested</li> <li>Server provisioned</li> <li>Client provisioned w/ table creation</li> </ol> <p>I've been very impressed with the relative simplicity of all of this. Then I realized the following:</p> <ul> <li>Schema created through client provisioning to SQLCE does not setup default values for uniqueidentifier types.</li> <li>FK constraints are not created on client</li> </ul> <p>Here is the code that is being used to create the client schema (pulled from an example I found somewhere online)</p> <pre><code>static void Provision() { SqlConnection serverConn = new SqlConnection( "Data Source=xxxxx, xxxx; Database=xxxxxx; " + "Integrated Security=False; Password=xxxxxx; User ID=xxxxx;"); // create a connection to the SyncCompactDB database SqlCeConnection clientConn = new SqlCeConnection( @"Data Source='C:\SyncSQLServerAndSQLCompact\xxxxx.sdf'"); // get the description of the scope from the SyncDB server database DbSyncScopeDescription scopeDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope( ScopeNames.Main, serverConn); // create CE provisioning object based on the scope SqlCeSyncScopeProvisioning clientProvision = new SqlCeSyncScopeProvisioning(clientConn, scopeDesc); clientProvision.SetCreateTableDefault(DbSyncCreationOption.CreateOrUseExisting); // starts the provisioning process clientProvision.Apply(); } </code></pre> <p>When Sync Framework creates the schema on the client I need to make the additional changes listed earlier (default values, constraints, etc.).</p> <p>This is where I'm getting confused (and frustrated): I came across a <a href="http://msdn.microsoft.com/en-us/library/bb726110.aspx" rel="nofollow">code example</a> that shows a SqlCeClientSyncProvider that has a CreatingSchema event. This code example actually shows setting the RowGuid property on a column which is EXACTLY what I need to do. However, what is a SqlCeClientSyncProvider?! This whole time (4 days now) I've been working with SqlCeSyncProvider in my sync code. So there is a SqlCeSyncProvider and a SqlCeClientSyncProvider?</p> <p>The documentation on MSDN is not very good in explaining what either of these.</p> <p>I've further confused whether I should make schema changes at provision time or at sync time?</p> <p>How would you all suggest that I make schema changes to the client CE schema during provisioning?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload