20240405075846_initial.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace WpfAppUI.Migrations
  5. {
  6. /// <inheritdoc />
  7. public partial class initial : Migration
  8. {
  9. /// <inheritdoc />
  10. protected override void Up(MigrationBuilder migrationBuilder)
  11. {
  12. migrationBuilder.CreateTable(
  13. name: "Posts",
  14. columns: table => new
  15. {
  16. id = table.Column<int>(type: "int", nullable: false)
  17. .Annotation("SqlServer:Identity", "1, 1"),
  18. Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
  19. },
  20. constraints: table =>
  21. {
  22. table.PrimaryKey("PK_Posts", x => x.id);
  23. });
  24. migrationBuilder.CreateTable(
  25. name: "Emploees",
  26. columns: table => new
  27. {
  28. id = table.Column<int>(type: "int", nullable: false)
  29. .Annotation("SqlServer:Identity", "1, 1"),
  30. Surname = table.Column<string>(type: "nvarchar(max)", nullable: false),
  31. Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
  32. Patronymic = table.Column<string>(type: "nvarchar(max)", nullable: true),
  33. PostId = table.Column<int>(type: "int", nullable: false),
  34. Birthday = table.Column<DateTime>(type: "date", nullable: false),
  35. Phone = table.Column<string>(type: "nvarchar(max)", nullable: false),
  36. Mail = table.Column<string>(type: "nvarchar(max)", nullable: false)
  37. },
  38. constraints: table =>
  39. {
  40. table.PrimaryKey("PK_Emploees", x => x.id);
  41. table.ForeignKey(
  42. name: "FK_Emploees_Posts_PostId",
  43. column: x => x.PostId,
  44. principalTable: "Posts",
  45. principalColumn: "id",
  46. onDelete: ReferentialAction.Cascade);
  47. });
  48. migrationBuilder.CreateIndex(
  49. name: "IX_Emploees_PostId",
  50. table: "Emploees",
  51. column: "PostId");
  52. }
  53. /// <inheritdoc />
  54. protected override void Down(MigrationBuilder migrationBuilder)
  55. {
  56. migrationBuilder.DropTable(
  57. name: "Emploees");
  58. migrationBuilder.DropTable(
  59. name: "Posts");
  60. }
  61. }
  62. }