public async Task Test2_SqlServer_SqlServer() { using var localDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test2_Local"); using var remoteDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test2_Remote"); await localDb.Database.EnsureDeletedAsync(); await remoteDb.Database.EnsureDeletedAsync(); await localDb.Database.MigrateAsync(); await remoteDb.Database.MigrateAsync(); var remoteConfigurationBuilder = new SqlSyncConfigurationBuilder(remoteDb.ConnectionString) .Table("Users") .Table("Posts") .Table("Comments"); var remoteSyncProvider = new SqlSyncProvider(remoteConfigurationBuilder.Build(), logger: new ConsoleLogger("REM")); await remoteSyncProvider.ApplyProvisionAsync(); var localConfigurationBuilder = new SqlSyncConfigurationBuilder(localDb.ConnectionString) .Table("Users") .Table("Posts") .Table("Comments"); var localSyncProvider = new SqlSyncProvider(localConfigurationBuilder.Build(), logger: new ConsoleLogger("LOC")); await localSyncProvider.ApplyProvisionAsync(); await Test2(localDb, localSyncProvider, remoteDb, remoteSyncProvider); }
public async Task Test_SqlServer_SqlServer_DeleteWithForeignKeys() { using var localDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test_Sqlite_Sqlite_DeleteWithForeignKeys_local"); using var remoteDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test_Sqlite_Sqlite_DeleteWithForeignKeys_remote"); await localDb.Database.EnsureDeletedAsync(); await remoteDb.Database.EnsureDeletedAsync(); await localDb.Database.MigrateAsync(); await remoteDb.Database.MigrateAsync(); var remoteConfigurationBuilder = new SqlSyncConfigurationBuilder(remoteDb.ConnectionString) .Table("Users") .Table("Posts") .Table("Comments"); var remoteSyncProvider = new SqlSyncProvider(remoteConfigurationBuilder.Build(), ProviderMode.Remote, logger: new ConsoleLogger("REM")); var localConfigurationBuilder = new SqlSyncConfigurationBuilder(localDb.ConnectionString) .Table("Users") .Table("Posts") .Table("Comments"); var localSyncProvider = new SqlSyncProvider(localConfigurationBuilder.Build(), ProviderMode.Local, logger: new ConsoleLogger("LOC")); await TestSyncAgentDeleteWithForeignKeys(localDb, localSyncProvider, remoteDb, remoteSyncProvider); }
public async Task Test1_SqlServer_Sqlite() { var remoteDbFile = $"{Path.GetTempPath()}Test1_SqlServer_Sqlite_remote.sqlite"; if (File.Exists(remoteDbFile)) { File.Delete(remoteDbFile); } using var localDb = new SqlServerBlogDbContext(ConnectionString + ";Initial Catalog=Test1_Local"); using var remoteDb = new SqliteBlogDbContext($"Data Source={remoteDbFile}"); await localDb.Database.EnsureDeletedAsync(); await remoteDb.Database.EnsureDeletedAsync(); await localDb.Database.MigrateAsync(); await remoteDb.Database.MigrateAsync(); var remoteConfigurationBuilder = new SqliteSyncConfigurationBuilder(remoteDb.ConnectionString) .Table <User>("Users") .Table <Post>("Posts") .Table <Comment>("Comments"); var remoteSyncProvider = new SqliteSyncProvider(remoteConfigurationBuilder.Build(), logger: new ConsoleLogger("REM")); await remoteSyncProvider.ApplyProvisionAsync(); var localConfigurationBuilder = new SqlSyncConfigurationBuilder(localDb.ConnectionString) .Table("Users") .Table("Posts") .Table("Comments"); var localSyncProvider = new SqlSyncProvider(localConfigurationBuilder.Build(), logger: new ConsoleLogger("LOC")); await localSyncProvider.ApplyProvisionAsync(); await Test1(localDb, localSyncProvider, remoteDb, remoteSyncProvider); }