I am trying to use EF Core code first migrations to de-normalise an existing table.
I have en existing table LoginEvent
which data looks like this:
You can execute any SQL using migrationBuilder.Sql(theSqlString)
.
In your case
migrationBuilder.Sql("INSERT INTO Venue SELECT DISTINCT VenueRef, VenueName FROM LoginEvent");
Run this in the migration after creating the new table Venue
and before dropping the old column VenueName
.
See also Custom Migrations Operations.