Dotmim.Sync
Dotmim.Sync copied to clipboard
Upgrade library from 0.6.1 to 0.9.4 on a DB with schema changes
We are using the library with version 0.6.1: SqlServer like remote DB and Sqlite for local one. After a database schema change, we tried to apply deprovision/provision following the sample from the documentation. But the provisioning was throwing the following error "Table AgendaInfo has no columns". We were trying to update even the library to the latest version (0.9.4) using some methods like UpgradeAsync (without finding any test for this operation). We found in one sample the method ForceUpgradeClientAsync that should upgrade the client DB. Can you tell us how to proceed in order to not lose the changes that are in pending on the remote and local repositories?
If DMS
is not able to Deprovision correctly your SQLITE client database, your best bet is to:
- Upgrade version to the latest
DMS
version (v0.95
is the last one when writing this post) - Keep the tracking tables for all the tables involved in your sync. THIS is the assurance you will not loose the changes to be uploaded to the server
- Only if these tables have still the same primary keys, otherwise, migrate the tracking tables with the correct primary key
- Update your SQLite schema using any tool / technic (sql statement, EF migration ...)
- Delete all triggers (update delete insert) for the tables involved in your sync.
- Call
UpgradeAsync()
to upgrade your SQLite database to the last version - Once it's done, call
ProvisionAsync
from the client, using this kind of code:
That should looks like this :
// Create local orchestrator
var localOrchestrator = new LocalOrchestrator(client.Provider);
var needToUpgrade = await localOrchestrator.NeedsToUpgradeAsync();
if (needToUpgrade)
await localOrchestrator.UpgradeAsync();
// Create a remote orchestrator
var remoteOrchestrator = new WebRemoteOrchestrator(serviceUri);
// Get the scope from server
var serverScope = await remoteOrchestrator.GetServerScopeInfoAsync();
// Apply scope locally to recreate everything we need
await localOrchestrator.ProvisionAsync(serverScope);
var agent = new SyncAgent(client.Provider, remoteOrchestrator, options);
var s = await agent.SynchronizeAsync(this.FilterParameters);
In order to delete all triggers, can we use the Deprovision method passing StoredProcedures and Triggers (without deleting the tracking tables)?
Deprovision(SyncProvision.StoredProcedures | SyncProvision.Triggers)
Yes, that should work
But since you have a problem with a table AgendaInfo
I'm not sure it will work for this one.
But yes, since you are not passing SyncProvision.TrackingTable
, you will not delete the tracking table