When you create migration in EF Core you can spice it up with arbitrary SQL query. Yet there is a limit to it -- maybe the migration is too complex in technical sense (i.e the SQL cannot handle it) or in readability sense (expressing the logic in SQL is too muddy). In short when migration logic can be only expressed in regular EF Core C# code with queries, filters, loops, ifs, etc.
Which leads to the question what are the patterns/solutions to handle/organize it?
So far I came up with idea of "freezing" type definitons (by copying them) of context, table models, and call of them let's say "FrozenVersion". Then on migration check if upcoming migration contains the "hot" step -- if yes, migrate it up to this step using FrozenVersion, execute special logic using this version, then disconnect from DB, switch to regular/current version of DB context, and models, connect back to DB, and migrate the rest using this version.
Clarification: this is general question about pattern which starts with "assume SQL is not enough for migration..." in the same sense as patterns for specific algorithms start "assume you have more data than RAM...".