using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace DEMO.Migrations { /// public partial class AddUsersAndRoles : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Roles", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Roles", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Login = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false), RoleId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); table.ForeignKey( name: "FK_Users_Roles_RoleId", column: x => x.RoleId, principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Users_RoleId", table: "Users", column: "RoleId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "Roles"); } } }