Advertisement

Advertisement

add new property in model in .net core 6

 Add new property in model in .net core 6

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"); } }

add new property in model in .net core 6 add new property in model in .net core 6 Reviewed by Rikesh on June 30, 2023 Rating: 5

No comments:

Powered by Blogger.