API
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.

20191021143440_MappingBank.cs 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. namespace UnivateProperties_API.Migrations
  3. {
  4. public partial class MappingBank : Migration
  5. {
  6. protected override void Up(MigrationBuilder migrationBuilder)
  7. {
  8. migrationBuilder.DropForeignKey(
  9. name: "FK_BankAccounts_Banks_BankId",
  10. table: "BankAccounts");
  11. //migrationBuilder.AddColumn<string>(
  12. // name: "Video",
  13. // table: "Properties",
  14. // nullable: true);
  15. //migrationBuilder.AddColumn<string>(
  16. // name: "VirtualTour",
  17. // table: "Properties",
  18. // nullable: true);
  19. migrationBuilder.AddColumn<int>(
  20. name: "BankAccountId",
  21. table: "Individuals",
  22. nullable: true);
  23. migrationBuilder.AlterColumn<int>(
  24. name: "BankId",
  25. table: "BankAccounts",
  26. nullable: true,
  27. oldClrType: typeof(int));
  28. migrationBuilder.AddColumn<int>(
  29. name: "OwnerId",
  30. table: "Addresses",
  31. nullable: true);
  32. migrationBuilder.CreateIndex(
  33. name: "IX_Individuals_BankAccountId",
  34. table: "Individuals",
  35. column: "BankAccountId");
  36. migrationBuilder.CreateIndex(
  37. name: "IX_Addresses_OwnerId",
  38. table: "Addresses",
  39. column: "OwnerId");
  40. migrationBuilder.AddForeignKey(
  41. name: "FK_Addresses_Individuals_OwnerId",
  42. table: "Addresses",
  43. column: "OwnerId",
  44. principalTable: "Individuals",
  45. principalColumn: "Id",
  46. onDelete: ReferentialAction.Restrict);
  47. migrationBuilder.AddForeignKey(
  48. name: "FK_BankAccounts_Banks_BankId",
  49. table: "BankAccounts",
  50. column: "BankId",
  51. principalTable: "Banks",
  52. principalColumn: "Id",
  53. onDelete: ReferentialAction.Restrict);
  54. migrationBuilder.AddForeignKey(
  55. name: "FK_Individuals_BankAccounts_BankAccountId",
  56. table: "Individuals",
  57. column: "BankAccountId",
  58. principalTable: "BankAccounts",
  59. principalColumn: "Id",
  60. onDelete: ReferentialAction.Restrict);
  61. }
  62. protected override void Down(MigrationBuilder migrationBuilder)
  63. {
  64. migrationBuilder.DropForeignKey(
  65. name: "FK_Addresses_Individuals_OwnerId",
  66. table: "Addresses");
  67. migrationBuilder.DropForeignKey(
  68. name: "FK_BankAccounts_Banks_BankId",
  69. table: "BankAccounts");
  70. migrationBuilder.DropForeignKey(
  71. name: "FK_Individuals_BankAccounts_BankAccountId",
  72. table: "Individuals");
  73. migrationBuilder.DropIndex(
  74. name: "IX_Individuals_BankAccountId",
  75. table: "Individuals");
  76. migrationBuilder.DropIndex(
  77. name: "IX_Addresses_OwnerId",
  78. table: "Addresses");
  79. //migrationBuilder.DropColumn(
  80. // name: "Video",
  81. // table: "Properties");
  82. //migrationBuilder.DropColumn(
  83. // name: "VirtualTour",
  84. // table: "Properties");
  85. migrationBuilder.DropColumn(
  86. name: "BankAccountId",
  87. table: "Individuals");
  88. migrationBuilder.DropColumn(
  89. name: "OwnerId",
  90. table: "Addresses");
  91. migrationBuilder.AlterColumn<int>(
  92. name: "BankId",
  93. table: "BankAccounts",
  94. nullable: false,
  95. oldClrType: typeof(int),
  96. oldNullable: true);
  97. migrationBuilder.AddForeignKey(
  98. name: "FK_BankAccounts_Banks_BankId",
  99. table: "BankAccounts",
  100. column: "BankId",
  101. principalTable: "Banks",
  102. principalColumn: "Id",
  103. onDelete: ReferentialAction.Cascade);
  104. }
  105. }
  106. }