Skip to content

Instantly share code, notes, and snippets.

@ssougnez
Last active January 14, 2026 20:47
Show Gist options
  • Select an option

  • Save ssougnez/3182179b71ab0d423267c4da2c622730 to your computer and use it in GitHub Desktop.

Select an option

Save ssougnez/3182179b71ab0d423267c4da2c622730 to your computer and use it in GitHub Desktop.
public class AppMigrationEngine: BaseMigrationEngine
{
public override async Task RunBeforeAsync()
{
// Runs before anything else
}
public override async Task RunBeforeDatabaseMigrationAsync(IDictionary < string, object > cache)
{
// Runs before EF Core migrations
// Use this to capture data before schema changes
var oldData = await _db.Orders.Select(o => new
{
o.Id, o.LegacyStatus
}).ToListAsync();
cache["oldStatuses"] = oldData;
}
public override async Task RunAfterDatabaseMigrationAsync()
{
// Runs after EF Core migrations, before application migrations
}
public override async Task RunAfterAsync()
{
// Runs after everything is done
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment