Oracle.ManagedDataAccess.EntityFramework 12.2.1100 Index names / migrations — oracle-tech

    Forum Stats

  • 3,716,134 Users
  • 2,242,961 Discussions
  • 7,845,841 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Oracle.ManagedDataAccess.EntityFramework 12.2.1100 Index names / migrations

Christian Ratzenhofer
Christian Ratzenhofer Member Posts: 2
edited May 2018 in ODP.NET

Today I started adding my indices to my code-first definition of the schema. While doing so I found out that all named indices never get removed when rolling back migrations.

The problem results from the fact, that the SQL generator in Oracle.ManagedDataAccess.EntityFramework ignores the actual supplied index name, but instead builds a new index name made up of IX_TABLENAME_COLUMN_COLUMN_... which then gets truncated to IX_TABLENAMEPART_SOMEDIGITS when the generated name is > 30 chars.

For the way back though visual studio creates a "Down" migration that only feeds in the custom name and no columns so the generated sql is "drop index "SCHEMA"."IX_TABLENAME_" which ofc doesn't exist.

The whole problem can be worked around by manualy editing the migration code and replacing the DropIndex call with a call that instead defines the columns, but that breaks my expectation that I can name the index with the IndexAttribute name property.

My actual question would be where or how do I file a bug for this?

Below a sample of the workaround for people that find the question:

A migration like this:

public partial class MIGRATIONNAME : DbMigration

{

    public override void Up() {

        CreateIndex("SCHEMA.BIGTABLE", new[] { "COLUMN1", "COLUMN2" }, name: "CUSTOMINDEXNAME");

    }

 

    public override void Down() {

        DropIndex("SCHEMA.BIGTABLE", "SCHEMA.CUSTOMINDEXNAME");

    }

}

Needs to be altered to this form:

public partial class MIGRATIONNAME : DbMigration

{

    public override void Up() {

        CreateIndex("SCHEMA.BIGTABLE", new[] { "COLUMN1", "COLUMN2" }, name: "CUSTOMINDEXNAME");

    }

 

    public override void Down() {

        DropIndex("SCHEMA.BIGTABLE", new[] { "COLUMN1", "COLUMN2" });

    }

}

Best Answer

Answers

This discussion has been closed.