20200721132516_Titles.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using Microsoft.EntityFrameworkCore.Metadata;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace GreenTree.Strohrmann.ERP.Domain.Migrations
  4. {
  5. public partial class Titles : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.AddColumn<int>(
  10. name: "TitleId",
  11. table: "Customers",
  12. nullable: false,
  13. defaultValue: 1);
  14. migrationBuilder.CreateTable(
  15. name: "Titles",
  16. columns: table => new
  17. {
  18. Id = table.Column<int>(nullable: false)
  19. .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
  20. Name = table.Column<string>(nullable: false)
  21. },
  22. constraints: table =>
  23. {
  24. table.PrimaryKey("PK_Titles", x => x.Id);
  25. });
  26. migrationBuilder.InsertData(
  27. table: "Titles",
  28. columns: new[] { "Id", "Name" },
  29. values: new object[,]
  30. {
  31. { 1, "Keiner" },
  32. { 2, "Herr" },
  33. { 3, "Frau" },
  34. { 4, "Firma" },
  35. { 5, "Familie" },
  36. { 6, "Eheleute" },
  37. { 7, "Herr und Frau" },
  38. { 8, "Prof." },
  39. { 9, "Dr." },
  40. { 10, "Dr. med." },
  41. { 11, "Prof. Dr." },
  42. { 12, "Prof. Dr. med." }
  43. });
  44. migrationBuilder.CreateIndex(
  45. name: "IX_Customers_TitleId",
  46. table: "Customers",
  47. column: "TitleId");
  48. migrationBuilder.AddForeignKey(
  49. name: "FK_Customers_Titles_TitleId",
  50. table: "Customers",
  51. column: "TitleId",
  52. principalTable: "Titles",
  53. principalColumn: "Id",
  54. onDelete: ReferentialAction.Restrict);
  55. }
  56. protected override void Down(MigrationBuilder migrationBuilder)
  57. {
  58. migrationBuilder.DropForeignKey(
  59. name: "FK_Customers_Titles_TitleId",
  60. table: "Customers");
  61. migrationBuilder.DropTable(
  62. name: "Titles");
  63. migrationBuilder.DropIndex(
  64. name: "IX_Customers_TitleId",
  65. table: "Customers");
  66. migrationBuilder.DropColumn(
  67. name: "TitleId",
  68. table: "Customers");
  69. }
  70. }
  71. }