Suppose, I want to replace table A with table B and migrate all data from one to another, so I do:
- Create table
Bthrough SQL query - Perform transformation over entire copy of data from
Aformat toBformat through SQL query - Put everything to
Btable through SQL query - Delete table
Athrough SQL query
The problem is, sometimes you need to break transaction and do non-transactional transform from A format to B format, which can even involve calls to different services (for example, new geo-political status of object from A, or different serialization contract of fields from A, 7zip it from A to B or whatever you desire to change about data in A).
So, the question is, how to accomplish step 2 through EF in any desirable way:
- Perform transformation over entire copy of data from
Aformat toBformat through "black box"
By that I mean not breaking concept of EF migration files, and providing me with something like "Main" method as entry point for my migration step. Any suggestions?
MigrationBuilder.Sql(). Not sure how you can get a proxy to the webservices into the migration though. See also Custom Migrations OperationsSqlmethod. Downside: you need a database downtime without external changes from the moment of Update-Database until the migration is fully applied - so pre-generating the migration SQL and executing it later is not a valid option.