本文整理汇总了C#中MigrationBuilder.DropForeignKey方法的典型用法代码示例。如果您正苦于以下问题:C# MigrationBuilder.DropForeignKey方法的具体用法?C# MigrationBuilder.DropForeignKey怎么用?C# MigrationBuilder.DropForeignKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MigrationBuilder
的用法示例。
在下文中一共展示了MigrationBuilder.DropForeignKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AspNetRoles_RoleGroups_RoleGroupId",
table: "AspNetRoles");
migrationBuilder.DropForeignKey(
name: "FK_RoleGroups_AspNetRoles_RoleId",
table: "RoleGroups");
migrationBuilder.DropIndex(
name: "IX_RoleGroups_RoleId",
table: "RoleGroups");
migrationBuilder.DropIndex(
name: "IX_AspNetRoles_RoleGroupId",
table: "AspNetRoles");
migrationBuilder.DropColumn(
name: "RoleId",
table: "RoleGroups");
migrationBuilder.DropColumn(
name: "RoleGroupId",
table: "AspNetRoles");
migrationBuilder.CreateTable(
name: "RoleRoleGroups",
columns: table => new
{
RoleId = table.Column<int>(nullable: false),
RoleGroupId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RoleRoleGroups", x => new { x.RoleId, x.RoleGroupId });
table.ForeignKey(
name: "FK_RoleRoleGroups_RoleGroups_RoleGroupId",
column: x => x.RoleGroupId,
principalTable: "RoleGroups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_RoleRoleGroups_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_RoleRoleGroups_RoleGroupId",
table: "RoleRoleGroups",
column: "RoleGroupId");
migrationBuilder.CreateIndex(
name: "IX_RoleRoleGroups_RoleId",
table: "RoleRoleGroups",
column: "RoleId");
}
示例2: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Photo_Album_AlbumId", table: "Photo");
migrationBuilder.DropForeignKey(name: "FK_UserRole_Role_RoleId", table: "UserRole");
migrationBuilder.DropForeignKey(name: "FK_UserRole_User_UserId", table: "UserRole");
migrationBuilder.AddColumn<string>(
name: "Throwaway",
table: "Album",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Photo_Album_AlbumId",
table: "Photo",
column: "AlbumId",
principalTable: "Album",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_UserRole_Role_RoleId",
table: "UserRole",
column: "RoleId",
principalTable: "Role",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_UserRole_User_UserId",
table: "UserRole",
column: "UserId",
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
示例3: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Resource_ResourceType_ResourceTypeId", table: "Resource");
migrationBuilder.DropForeignKey(name: "FK_Resource_Supplier_SupplierId", table: "Resource");
migrationBuilder.DropForeignKey(name: "FK_Supplier_Address_AddressId", table: "Supplier");
migrationBuilder.AddForeignKey(
name: "FK_Resource_ResourceType_ResourceTypeId",
table: "Resource",
column: "ResourceTypeId",
principalTable: "ResourceType",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Resource_Supplier_SupplierId",
table: "Resource",
column: "SupplierId",
principalTable: "Supplier",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Supplier_Address_AddressId",
table: "Supplier",
column: "AddressId",
principalTable: "Address",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例4: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_ReleaseBatchItem_ReleaseBatch_ReleaseBatchId", schema: "kraken", table: "ReleaseBatchItem");
migrationBuilder.DropForeignKey(name: "FK_ReleaseBatchLogo_ReleaseBatch_ReleaseBatchId", schema: "kraken", table: "ReleaseBatchLogo");
migrationBuilder.DropColumn(name: "IsLocked", schema: "kraken", table: "ReleaseBatch");
migrationBuilder.DropColumn(name: "LockComment", schema: "kraken", table: "ReleaseBatch");
migrationBuilder.DropColumn(name: "LockUserName", schema: "kraken", table: "ReleaseBatch");
migrationBuilder.AddForeignKey(
name: "FK_ReleaseBatchItem_ReleaseBatch_ReleaseBatchId",
schema: "kraken",
table: "ReleaseBatchItem",
column: "ReleaseBatchId",
principalSchema: "kraken",
principalTable: "ReleaseBatch",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ReleaseBatchLogo_ReleaseBatch_ReleaseBatchId",
schema: "kraken",
table: "ReleaseBatchLogo",
column: "ReleaseBatchId",
principalSchema: "kraken",
principalTable: "ReleaseBatch",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
示例5: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Category_Article", table: "Article");
migrationBuilder.DropForeignKey(name: "FK_Section_Category", table: "Category");
migrationBuilder.AlterColumn<int>(
name: "SectionId",
table: "Section",
nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "Section",
nullable: false,
defaultValue: false);
migrationBuilder.AddForeignKey(
name: "FK_Category_Article",
table: "Article",
column: "CategoryId",
principalTable: "Category",
principalColumn: "CategoryId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Section_Category",
table: "Category",
column: "SectionId",
principalTable: "Section",
principalColumn: "SectionId",
onDelete: ReferentialAction.Cascade);
}
示例6: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Photo_Album_AlbumId", table: "Photo");
migrationBuilder.DropForeignKey(name: "FK_UserRole_Role_RoleId", table: "UserRole");
migrationBuilder.DropForeignKey(name: "FK_UserRole_User_UserId", table: "UserRole");
migrationBuilder.DropColumn(name: "Throwaway", table: "Album");
migrationBuilder.AddForeignKey(
name: "FK_Photo_Album_AlbumId",
table: "Photo",
column: "AlbumId",
principalTable: "Album",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UserRole_Role_RoleId",
table: "UserRole",
column: "RoleId",
principalTable: "Role",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UserRole_User_UserId",
table: "UserRole",
column: "UserId",
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例7: Down
public override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey("AspNetRoleClaims", "FK_AspNetRoleClaims_AspNetRoles_RoleId");
migrationBuilder.DropForeignKey("AspNetUserClaims", "FK_AspNetUserClaims_AspNetUsers_UserId");
migrationBuilder.DropForeignKey("AspNetUserLogins", "FK_AspNetUserLogins_AspNetUsers_UserId");
migrationBuilder.DropForeignKey("CourseTracker", "FK_CourseTracker_AspNetUsers_ApplicationUserId");
migrationBuilder.DropForeignKey("CourseTracker", "FK_CourseTracker_Course_CourseID");
migrationBuilder.DropTable("AspNetRoles");
migrationBuilder.DropTable("AspNetRoleClaims");
migrationBuilder.DropTable("AspNetUserClaims");
migrationBuilder.DropTable("AspNetUserLogins");
migrationBuilder.DropTable("AspNetUserRoles");
migrationBuilder.DropTable("AspNetUsers");
migrationBuilder.DropTable("Course");
migrationBuilder.DropTable("CourseTracker");
}
示例8: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_BatNodeLog_BatCall_FirstCallId", table: "BatNodeLogs");
migrationBuilder.DropForeignKey(name: "FK_BatNodeLog_BatCall_LastCallId", table: "BatNodeLogs");
migrationBuilder.DropTable("BatCalls");
migrationBuilder.DropTable("BatNodeLogs");
}
示例9: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_MenuItem_Category_CategoryId", table: "MenuItem");
migrationBuilder.DropForeignKey(name: "FK_OrderItem_Order_OrderId", table: "OrderItem");
migrationBuilder.AlterColumn<int>(
name: "Id",
table: "OrderItem",
nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
migrationBuilder.AddColumn<decimal>(
name: "Total",
table: "Order",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddForeignKey(
name: "FK_MenuItem_Category_CategoryId",
table: "MenuItem",
column: "CategoryId",
principalTable: "Category",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_OrderItem_Order_OrderId",
table: "OrderItem",
column: "OrderId",
principalTable: "Order",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
示例10: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserLogins",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "UserId",
table: "AspNetUserClaims",
nullable: false);
migrationBuilder.AlterColumn<string>(
name: "RoleId",
table: "AspNetRoleClaims",
nullable: false);
migrationBuilder.AddColumn<string>(
name: "Discriminator",
table: "AspNetRoles",
nullable: false,
defaultValue: "");
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例11: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Category_Article", table: "Article");
migrationBuilder.DropForeignKey(name: "FK_Section_Category", table: "Category");
migrationBuilder.AlterColumn<string>(
name: "Url",
table: "Section",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "Title",
table: "Section",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "Url",
table: "Category",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "Title",
table: "Category",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Category_Article",
table: "Article",
column: "CategoryId",
principalTable: "Category",
principalColumn: "CategoryId",
onDelete: ReferentialAction.Restrict);
}
示例12: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_PriceHistory_Stock_StockId", table: "PriceHistory");
migrationBuilder.DropForeignKey(name: "FK_Txn_Stock_StockId", table: "Txn");
migrationBuilder.AlterColumn<decimal>(
name: "Open",
table: "PriceHistory",
nullable: false);
migrationBuilder.AlterColumn<decimal>(
name: "Low",
table: "PriceHistory",
nullable: false);
migrationBuilder.AlterColumn<decimal>(
name: "High",
table: "PriceHistory",
nullable: false);
migrationBuilder.AlterColumn<decimal>(
name: "Close",
table: "PriceHistory",
nullable: false);
migrationBuilder.AddForeignKey(
name: "FK_PriceHistory_Stock_StockId",
table: "PriceHistory",
column: "StockId",
principalTable: "Stock",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Txn_Stock_StockId",
table: "Txn",
column: "StockId",
principalTable: "Stock",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
示例13: Up
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.CreateTable(
name: "Event",
columns: table => new
{
ID = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
CompleteAddress = table.Column<string>(nullable: true),
EventEnd = table.Column<DateTime>(nullable: false),
EventStart = table.Column<DateTime>(nullable: false),
IsCurrent = table.Column<bool>(nullable: false),
Name = table.Column<string>(nullable: true),
SocialMediaHashtag = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Event", x => x.ID);
});
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
示例14: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_Produto_Categoria_CategoriaID", table: "Produto");
migrationBuilder.DropForeignKey(name: "FK_ProdutoVenda_Produto_ProdutoID", table: "ProdutoVenda");
migrationBuilder.DropForeignKey(name: "FK_ProdutoVenda_Venda_VendaID", table: "ProdutoVenda");
migrationBuilder.DropColumn(name: "Discriminator", table: "Usuario");
migrationBuilder.DropColumn(name: "CPF", table: "Usuario");
migrationBuilder.DropColumn(name: "CNPJ", table: "Usuario");
migrationBuilder.AddForeignKey(
name: "FK_Produto_Categoria_CategoriaID",
table: "Produto",
column: "CategoriaID",
principalTable: "Categoria",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ProdutoVenda_Produto_ProdutoID",
table: "ProdutoVenda",
column: "ProdutoID",
principalTable: "Produto",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_ProdutoVenda_Venda_VendaID",
table: "ProdutoVenda",
column: "VendaID",
principalTable: "Venda",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
}
示例15: Down
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_OpeningHours_Shop_ShopId", table: "OpeningHours");
migrationBuilder.DropForeignKey(name: "FK_Prize_Shop_ShopId", table: "Prize");
migrationBuilder.DropForeignKey(name: "FK_Puzzle_Shop_ShopId", table: "Puzzle");
migrationBuilder.AddForeignKey(
name: "FK_OpeningHours_Shop_ShopId",
table: "OpeningHours",
column: "ShopId",
principalTable: "Shop",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Prize_Shop_ShopId",
table: "Prize",
column: "ShopId",
principalTable: "Shop",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Puzzle_Shop_ShopId",
table: "Puzzle",
column: "ShopId",
principalTable: "Shop",
principalColumn: "ID",
onDelete: ReferentialAction.Restrict);
}