I have a Code First EF Core project.
In my schema migration, I need to do a data migration to an external database. So I can't fall back on migrationBuilder.Sql(). What I need to do is run a query on the local database and insert the data returned into the external database. In other words, I want to do something like this:
// Obviously this is pseudo-code; these interfaces mostly don't exist protected override void Up(MigrationBuilder migrationBuilder) { var results = migrationBuilder.GetQueryResults("some query"); using (var extDb = new ExternalDb()) { foreach (var row in results) { InsertToExternalDb(row, extDb); } } } But I can't find any method on MigrationBuilder that returns rows from the current database, and I can't even find a way to get the connection string such that I could write a raw ADO query to the current database.
Any other ideas how I could do this?