Bug #89332 EntityFramework Back Version Migration Removing Index Fails.
Submitted: 20 Jan 2018 1:25 Modified: 22 Jun 2018 5:46
Reporter: Richard Collette Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S4 (Feature request)
Version:6.10.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: entityframework

[20 Jan 2018 1:25] Richard Collette
Description:
This was already reported to Microsoft and identified as a provider issue.
https://github.com/aspnet/EntityFrameworkCore/issues/10702#issuecomment-358380406

Exception while reverting a single index using the command:
`dotnet ef database update InitialMigration`

```
Exception message: System.ArgumentNullException: Value cannot be null. Parameter name: model
Stack trace:
MySql.Data.EntityFrameworkCore.Migrations.MySQLMigrationsSqlGenerator.Generate(DropIndexOperation operation, IModel model, MigrationCommandListBuilder builder)
   at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder)
   at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(IReadOnlyList`1 operations, IModel model)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateDownSql(Migration migration, Migration previousMigration)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
```

```c#
namespace PitneyBowes.SendPro.Locations.Migrations
{
    public partial class DefaultLocationUniqueness : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateIndex(
                name: "IX_locations_subscription_id_is_default",
                table: "locations",
                columns: new[] { "subscription_id", "is_default" },
                unique: true);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "IX_locations_subscription_id_is_default",
                table: "locations");
        }
    }
}
```

### Further technical details
EF Core version: 2.0.1
Database Provider: MySql.Data.EntityFrameworkCore 6.10.5
Operating system: OSX
IDE: VSCode

How to repeat:
Create a code first migration that adds an index to an existing database table.
Deploy the migration.

Try to revert the migration by running `dotnet ef database update priorMigration`
[25 Jan 2018 7:33] Chiranjeevi Battula
Hello Richard Collette,

Thank you for the bug report.
As per internal discussion with developers and they confirm that index in EF Core migrations are not supporting.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.
[25 Jan 2018 13:57] Richard Collette
How could you have closed this as not a bug?   Is it the intent of the team to not support the feature set of EntityFramework?   Is this project being shut down?  Is it the advice of the team to use another driver?
[25 Jan 2018 17:46] Roberto Ezequiel Garcia Ballesteros
Hi,

Currently indexes in migrations are not suppported.

I'm sorry for the inconvenience.
[22 Jun 2018 5:46] Chiranjeevi Battula
Hello Richard Collette,

Thank you for the bug report.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.