static IntegrationTestsBase() { const string pattern = @"Migration(\d+)"; Migrations.AddRange(typeof(IntegrationTestsBase).Assembly.GetTypes() .Where(t => Regex.IsMatch(t.Name, pattern) && t.GetInterface("IMigration") != null) .OrderBy(t => long.Parse(Regex.Match(t.Name, pattern).Groups[1].Value, CultureInfo.InvariantCulture)) .Select(t => (IMigration)Activator.CreateInstance(t))); Timestamps = new List <long>(Migrations.Select(m => TimestampProvider.GetTimestamp(m.GetType()))); MigrationOptions.SetGeneralTraceLevel(SourceLevels.All); MigrationOptions.SetPerformanceTraceLevel(SourceLevels.All); MigrationOptions.SetSqlTraceLevel(SourceLevels.All); }
private static void Main() { CommandLineOptions commandLineOptions; CommandLineParser parser; if (DisplayHelp(Environment.CommandLine, out commandLineOptions, out parser)) { Console.WriteLine(GetUsageMessage(parser)); Environment.Exit(SuccessExitCode); } string connectionString; string providerName; string assemblyPath; string[] additionalAssemblyPaths; long timestamp; SourceLevels traceLevels; MigrationOptions options; try { options = ParseCommandLineArguments(commandLineOptions, parser, ConfigurationManager.ConnectionStrings, out connectionString, out providerName, out assemblyPath, out additionalAssemblyPaths, out timestamp, out traceLevels); } catch (InvalidCommandLineArgumentException x) { Console.Error.WriteLine(x.Message); Environment.Exit(x.ExitCode); throw; // will not be executed; just to satisfy R# } Trace.Listeners.Add(new ConsoleTraceListener()); // IMPORTANT: do this before setting the trace levels MigrationOptions.SetGeneralTraceLevel(traceLevels); MigrationOptions.SetSqlTraceLevel(traceLevels); MigrationOptions.SetPerformanceTraceLevel(traceLevels); try { ExecuteMigration(connectionString, providerName, options, assemblyPath, timestamp, additionalAssemblyPaths); } catch (Exception x) { Console.Error.WriteLine(string.Format(CultureInfo.CurrentCulture, "Failed to migrate: {0}", GetErrorMessage(x))); Environment.Exit(FailedMigrationExitCode); } }