Script EF migration seed from Configuration class

前端 未结 3 1483
终归单人心
终归单人心 2021-01-01 11:07

I have EF migrations working nicely, but I also want to generate the sql script for the seed data from my DbMigrationsConfiguration class. The seed data runs ok when I do Up

3条回答
  •  抹茶落季
    2021-01-01 11:27

    No it is not possible. Configuration class is not part of migration itself - it is infrastructure executing the migration. You have single configuration class for all your migrations and its Seed method is executed after every migration run - you can even use context for seeding data and because of that this method is executed after the migration is completed = it cannot be part of migration. Only content of the migration class is scripted.

提交回复
热议问题