Entity framework core, code first migration with data migration

前端 未结 1 1730
南旧
南旧 2021-01-12 08:09

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:

相关标签:
1条回答
  • 2021-01-12 08:26

    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.

    0 讨论(0)
提交回复
热议问题