You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20230217144058_UserCategoryManyToMany.cs 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Diligent.WebAPI.Data.Migrations
  4. {
  5. public partial class UserCategoryManyToMany : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "UserCategories",
  11. columns: table => new
  12. {
  13. Id = table.Column<int>(type: "int", nullable: false)
  14. .Annotation("SqlServer:Identity", "1, 1"),
  15. UserId = table.Column<int>(type: "int", nullable: false),
  16. CategoryId = table.Column<int>(type: "int", nullable: false)
  17. },
  18. constraints: table =>
  19. {
  20. table.PrimaryKey("PK_UserCategories", x => x.Id);
  21. table.ForeignKey(
  22. name: "FK_UserCategories_AspNetUsers_UserId",
  23. column: x => x.UserId,
  24. principalTable: "AspNetUsers",
  25. principalColumn: "Id",
  26. onDelete: ReferentialAction.Cascade);
  27. table.ForeignKey(
  28. name: "FK_UserCategories_Categories_CategoryId",
  29. column: x => x.CategoryId,
  30. principalTable: "Categories",
  31. principalColumn: "Id",
  32. onDelete: ReferentialAction.Cascade);
  33. });
  34. migrationBuilder.CreateIndex(
  35. name: "IX_UserCategories_CategoryId",
  36. table: "UserCategories",
  37. column: "CategoryId");
  38. migrationBuilder.CreateIndex(
  39. name: "IX_UserCategories_UserId",
  40. table: "UserCategories",
  41. column: "UserId");
  42. }
  43. protected override void Down(MigrationBuilder migrationBuilder)
  44. {
  45. migrationBuilder.DropTable(
  46. name: "UserCategories");
  47. }
  48. }
  49. }