Here is the code that produce this error. I've tried solution for renaming the AddForeignKey
but the error is same.
'PK_dbo.Item' is not a constraint.
Could not drop constraint. See previous errors.
Can you suggest some solution?
public override void Up()
{
DropForeignKey("dbo.AddGallery", "item_fk_id", "dbo.Item");
DropForeignKey("dbo.ExtraFieldValue", "item_fk_id", "dbo.Item");
DropPrimaryKey("dbo.Item");
AddColumn("dbo.Item", "id", c => c.Int(nullable: false, identity: true));
AddPrimaryKey("dbo.Item", "id");
AddForeignKey("dbo.AddGallery", "item_fk_id", "dbo.Item", "id");
AddForeignKey("dbo.ExtraFieldValue", "item_fk_id", "dbo.Item", "id");
DropColumn("dbo.Item", "item_id");
}
public override void Down()
{
AddColumn("dbo.Item", "item_id", c => c.Int(nullable: false, identity: true));
DropForeignKey("dbo.ExtraFieldValue", "item_fk_id", "dbo.Item");
DropForeignKey("dbo.AddGallery", "item_fk_id", "dbo.Item");
DropPrimaryKey("dbo.Item");
DropColumn("dbo.Item", "id");
AddPrimaryKey("dbo.Item", "item_id");
AddForeignKey("dbo.ExtraFieldValue", "item_fk_id", "dbo.Item", "id");
AddForeignKey("dbo.AddGallery", "item_fk_id", "dbo.Item", "id");
}
I believe the primary key no longer exists and this is why it cannot be dropped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With