/// <summary> /// 备份数据库 /// </summary> /// <param name="daoFactory"></param> /// <param name="migrationOptions"></param> /// <returns></returns> public static async Task Backup(this IDaoFactory daoFactory, MigrationOptions migrationOptions) { if (!migrationOptions?.IsBackup == true) { await Task.CompletedTask; } var daoFactoryOption = daoFactory.DaoFactoryOption; switch (daoFactoryOption.DbType) { case DbTypes.MsSqlServer: //todo break; case DbTypes.MySql: //todo break; case DbTypes.NpgSql: { var provider = new PostgreSqlBackupProvider(daoFactoryOption, migrationOptions); await provider.Backup(); break; } case DbTypes.Sqlite: //todo break; default: break; } }
public static IServiceCollection AddAutoMigration(this IServiceCollection services, Action <MigrationOptions> options) { var migrationOptions = new MigrationOptions(); options.Invoke(migrationOptions); services.AddSingleton(s => migrationOptions); services.AddScoped <AutoMigration>(); return(services); }