Mimetis / Dotmim.Sync

A brand new database synchronization framework, multi platform, multi databases, developed on top of .Net Standard 2.0. https://dotmimsync.readthedocs.io/
MIT License
855 stars 188 forks source link

Unable to Update Scope Info in SQL Server Sync with RemoteOrchestrator #1207

Open nicolazreinh opened 4 days ago

nicolazreinh commented 4 days ago

Description: I am experiencing an issue with updating the scope info using the Dotmim.Sync library. I am using ASP.NET Core Web Proxy with change tracking in SQL Server.

Steps to Reproduce:

  1. Call:
    await remoteOrchestrator.DeprovisionAsync(scopeName, SyncProvision.ScopeInfo);
  2. Verify that the scope info is not removed.
  3. Attempt to update the scope info using:
    await remoteOrchestrator.ProvisionAsync(scopeName, setup, overwrite: true);
  4. Verify that the old scope info remains unchanged.

Expected Behavior: Calling DeprovisionAsync should remove the scope info, and ProvisionAsync with overwrite set to true should refresh and update the scope info as documented.

Actual Behavior:

Additional Context:

Any assistance in resolving this issue would be greatly appreciated. Thank you!

Mimetis commented 3 days ago

DeprovisionAsync(SyncProvision.ScopeInfo) removes the table itself. It's literally a DROP TABLE query that is excuted behind the scene

Just tried with AdventureWorks; and it's seems it's working fine for me:

 var remoteOrchestrator = new RemoteOrchestrator(serverProvider, options);
 await remoteOrchestrator.DeprovisionAsync(SyncProvision.ScopeInfo);

image

And ProvisionAsync is all about creating the tracking table, the stored procedures, the scope info table and the scope info record if needed

IF you ONLY want to remove a ScopeInfo, you can do it, using the DeleteScopeInfoAsync method:

var remoteOrchestrator = new RemoteOrchestrator(serverProvider, options);

var scopeInfo = await remoteOrchestrator.GetScopeInfoAsync(scopeName);
await remoteOrchestrator.DeleteScopeInfoAsync(scopeInfo);

IF you want to recreate a scope, you don't have to explicitly create it, just call a ProvisionAsync that will:

// Create a new setup for a new scope:
var newSetup = new SyncSetup("Customer", "CustomerAddress");

// Provision will create everything needed for this scope and will return the new scope
var newScopeInfo = await remoteOrchestrator.ProvisionAsync("CustomerScope", newSetup);

And finally, if you just want to overwrite an existing scope (without deleting it before) you can use the overwrite thing:

// Create a new setup for a new scope:
var newSetup = new SyncSetup("Address", "Customer", "CustomerAddress");

// Provision will create everything needed for this scope and will return the new scope
var newScopeInfo = await remoteOrchestrator.ProvisionAsync("CustomerScope", newSetup, overwrite:true);

Make sense ?