Change data in migration Up method - Entity Framework

后端 未结 4 1490
一向
一向 2020-12-14 05:48

I have added a new property into my existing model. It\'s a bool property with default value true. There are existing data in this table and I would like to set one specific

4条回答
  •  难免孤独
    2020-12-14 06:25

    Instead of using the Sql method you could also use the UpdateData method.

    migrationBuilder.UpdateData(
        table: "RequestValidationErrors", 
        keyColumn: "WordCode", 
        keyValue: "RequestValidationError.MoreThanOneItemFound", 
        column: "IsBreaking", 
        value: false);
    

    (I don't know if only ef core supports this method)

提交回复
热议问题