Entity framework更新种子数据-数据移动迁移

Entity framework update seed data - data motion migration

我的种子数据使用HasData方法插入:

modelBuilder.Entity<SystemResource>().HasData(new[]
{
    new SystemResource()
    {
        Id = 1,
        Code = "roi-dev-003",
        IsEnabled = true,
    }
});

我想将生成的种子数据的 Code 属性 的值更改为新值。可以使用种子数据完成还是需要 sql 更新数据库?

HasData方法的签名说它是用来产生数据运动迁移的。数据移动迁移如何工作?

更新: 更改 Code 属性 的值然后 运行 update-database 没有效果:

PM> update-database
No migrations were applied. The database is already up to date.

遗憾的是,目前 EFCore 似乎不支持此功能。

这篇 article 是对 HasData 系统的相当深入的概述。它的这一行是相关的:

But HasData isn’t a silver bullet. Keep in mind that this feature is best for seed data that will remain static once it’s been inserted into the database.

我也一直在寻找解决这个问题的好办法