I am using Pomelo Entity Franework Core MySql Provider and I have scaffolded a migration, that drops an index in a MySql database. It looks this
public partial class IndexUpdate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Buildings_AddressId",
table: "Buildings");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Buildings_AddressId",
table: "Buildings",
column: "AddressId",
unique: true);
}
}
The database contains this index and it has a type of UNIQUE. When I conduct the migration an error occurs with the following message:
Cannot drop index 'IX_Buildings_AddressId': needed in a foreign key constraint
I fully understand that it is a basic sql drop index operation, I have found this solution. My question is: is there a way not to drop and create a foreign key in order to drop index? I would prefer to resolve the problem in terms of Entity Framework/MySql provider rather than raw Sql