If you don't like writing/changing the required code in the Migration class manually, you can follow a two-step approach which automatically make the RenameColumn
code which is required:
Step One Use the ColumnAttribute
to introduce the new column name and then add-migration (e.g. Add-Migration ColumnChanged
)
public class ReportPages
{
[Column("Section_Id")] //Section_Id
public int Group_Id{get;set}
}
Step-Two change the property name and again apply to same migration (e.g. Add-Migration ColumnChanged -force
) in the Package Manager Console
public class ReportPages
{
[Column("Section_Id")] //Section_Id
public int Section_Id{get;set}
}
If you look at the Migration class you can see the automatically code generated is RenameColumn
.