I have a question about editing migration files in
Example: I have created 3 tables using separate migration for each:
After that several days later I decided to change the type of
status column in
Table1 to be
int and not
After updating the
AddTable1 migration file, deleting the database and executing
update-database command the column was still defined with
I noticed that all the
.Designer.cs files still were using
string type for
status column despite my edit of
Table1 migration file.
I copied the content of the
AppDbContextModelSnapshot.cs file and manually updated all the
.Designer.cs files for all migrations (note: the method name in source and
.Designer.cs files is different).
And that helped. I'm sure that this is not the recommended way to use migrations.
My question is: is there a command which will do what I did - 'reset' the '.Designer.cs' files?
If not, how to make one? :)
Think of migrations as Git commits. You don't rewrite previous commits once you've shared them with other team members (or in our case, applied a migration to a database). Instead, you create new migrations with additional changes.
If you haven't applied a migration or shared it with teammates, you can remove it and re-scaffold:
Remove-Migration Add-Migration FixedUpMigration
See the EF Core Migrations docs for basic usage.