Change data in migration Up method - Entity Framework

后端 未结 4 1486
一向
一向 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:07

    If you want to use the framework for changes like this, you should separate Database changes from Data changes.

    Create a migration for just the Database changes, and execute.

    Then create a new migration (the Up() and Down() methods will be empty). You can now instantiate your DatabaseContext and there will be no error. This way you can use the Framework for these changes, and properly implement a Down() method.

提交回复
热议问题