使用 fluentmigrator 时从数据库中删除一行

Removing a row form the database when working with the fluent migration

我是 Fluent Migrations 的新手。我只想从数据库中删除一行,你能指导我如何做到这一点吗? 如果这个问题已经在 Whosebug 的其他地方得到回答,或者指出我正确的方向。 我不想在迁移脚本中使用动态 sql。

谢谢。

我从 wiki 找到了答案。 以下是可用于迁移以从数据库中删除行的格式

Delete.FromTable("Users").Row(new { FirstName = "John" }); // 删除 FirstName==John

的所有行

要删除迁移中的行,只需执行以下操作:

//Delete all rows where MyColumn = 123
Delete.FromTable("MyTable").Row(new { MyColumn = "123" }); 

FluentMigrator 的文档是解决此类问题的好地方。您要找的文章可以在 here 找到。