protected override async void Execute() { string bd = CloudConfigurationManager.GetSetting("DatabaseConnectionString"); var query = new GetDatabaseSizeRecommendation(databaseName); DatabaseSizeRecommendation recommendation = await Database <EmptyDbContext> .Model(() => new EmptyDbContext(bd)) .WithCache() .QueryAsync(query); DatabaseSizeRecommendation databaseSizeRecommendation = recommendation; ReportRecommendations(databaseSizeRecommendation); if (databaseSizeRecommendation.CurrentMaxSize == databaseSizeRecommendation.MaxSize) { return; } if (databaseSizeRecommendation.CurrentMaxSize == absoluteMaxSize) { return; } if (databaseSizeRecommendation.MaxSize > absoluteMaxSize) { return; } Report(Resources.SqlDatabaseAutoScaler_Applying_Recommendations); string m = CloudConfigurationManager.GetSetting("MasterDatabaseConnectionString"); Task result = Database <EmptyDbContext> .Model(() => new EmptyDbContext(m)) .DoWithoutTransactionAsync(model => model.Database.ExecuteSqlCommand("ALTER DATABASE [" + databaseName + "] MODIFY (EDITION='" + databaseSizeRecommendation.Edition + "', MAXSIZE=" + databaseSizeRecommendation.MaxSize + "GB)")); result.Wait(); }
protected override async void Execute() { var bd = CloudConfigurationManager.GetSetting("DatabaseConnectionString"); var query = new GetDatabaseSizeRecommendation(databaseName); var recommendation = await Database<EmptyDbContext> .Model(() => new EmptyDbContext(bd)) .WithCache() .QueryAsync(query); var databaseSizeRecommendation = recommendation; ReportRecommendations(databaseSizeRecommendation); if (databaseSizeRecommendation.CurrentMaxSize == databaseSizeRecommendation.MaxSize) return; if (databaseSizeRecommendation.CurrentMaxSize == absoluteMaxSize) return; if (databaseSizeRecommendation.MaxSize > absoluteMaxSize) return; Report(Resources.SqlDatabaseAutoScaler_Applying_Recommendations); var m = CloudConfigurationManager.GetSetting("MasterDatabaseConnectionString"); var result = Database<EmptyDbContext>.Model(() => new EmptyDbContext(m)) .DoWithoutTransactionAsync(model => model.Database.ExecuteSqlCommand("ALTER DATABASE [" + databaseName + "] MODIFY (EDITION='" + databaseSizeRecommendation.Edition + "', MAXSIZE=" + databaseSizeRecommendation.MaxSize + "GB)")); result.Wait(); }