/// <summary> /// On migration complete event /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public static void OnMigrationCompleteHandler(object sender, DatabaseMigrateEventArgs args) { //Trigger seed data Console.WriteLine($"Context {args.ContextName}"); SystemEvents.Database.Seed(new DatabaseSeedEventArgs { DbContext = args.DbContext, ContextName = args.ContextName }); }
/// <summary> /// On migration complete event /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public static void OnMigrationCompleteHandler(object sender, DatabaseMigrateEventArgs args) { Console.WriteLine($"Context {args.ContextName}"); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"Context {args.ContextName} migrated in {TimeSpan.FromMilliseconds(args.ElapsedMilliseconds).TotalMinutes} minutes"); Console.ForegroundColor = ConsoleColor.White; //Trigger seed data SystemEvents.Database.Seed(new DatabaseSeedEventArgs { DbContext = args.DbContext, ContextName = args.ContextName }); }
/// <summary> /// Invoke seed event /// </summary> /// <param name="e"></param> public static void MigrateComplete(DatabaseMigrateEventArgs e) => InvokeEvent(null, OnMigrateComplete, e, nameof(OnMigrateComplete));