@Cenk , based on my test, you could try the following steps to add a new property to a model and the related database.
First, Please add the property in the model class.
public class Student
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public string Address { get; set; }
public int Score { get; set; } // Added property
}
Second, Please execute the following commands in sequence in the Package Console below.
Enable-Migrations
Add-Migration AddFileld
Update-Database
Finally, you could see the results in the code and database.
Code:
public partial class AddFileld : DbMigration
{
public override void Up()
{
AddColumn("dbo.Students", "Score", c => c.Int(nullable: false));
}
public override void Down()
{
DropColumn("dbo.Students", "Score");
}
}
Result:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.