using Microsoft.EntityFrameworkCore.Migrations; public partial class AddNewColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .AddColumn( name: "NewColumn", table: "ExistingTable"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .DropColumn( name: "NewColumn", table: "ExistingTable"); } }
using Microsoft.EntityFrameworkCore.Migrations; public partial class ModifyColumn : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .AlterColumnIn summary, MigrationBuilder.AlterDatabase is a useful method for making changes to an existing database schema using C# code. It is part of the EntityFrameworkCore package library. The examples above show how to add a new column to a table and modify an existing column's attributes.( name: "ExistingColumn", table: "ExistingTable", maxLength: 50, oldMaxLength: 25); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .AlterColumn ( name: "ExistingColumn", table: "ExistingTable", maxLength: 25, oldMaxLength: 50); } }