❔ How to handle migration with column changes in Ef Core code first?

I need to change a table which is already in production.

Specifically I need to change a field which is currently an integer which represents a week number.
I now need to change it to a proper datatime.

Ideally I would like to do something like this:
  1. Add a new column to the table - StartDate
  2. Add some code to the migration Up file which runs through all the instances of that table and reads the StartWeek column and writes to the StartDate
  3. Remove the StartWeek column
What is the best practice for handling this?
Was this page helpful?