create non clustered index on primary key entity framework 6.0 -


i aware of this, states not possible create primary key non clustered index via code first. still case?

ideally, specify via entitytypeconfiguration, primary key (guid) has non-clustered index , there column (int) clustered index.

afaik not possible entitytypeconfiguration. can code-first migrations. working example:

public class product {     public guid id     { get; set; }      public int price     { get; set; } }  class appdbcontext : dbcontext {     public dbset<product> products     { get; set; } }  public partial class initialcreate : dbmigration {     public override void up()     {         createtable(             "dbo.products",             c => new                 {                     id = c.guid(nullable: false),                     price = c.int(nullable: false),                 })             .primarykey(t => t.id, clustered: false)             .index(t => t.price, clustered: true);      }      public override void down()     {         dropindex("dbo.products", new[] { "price" });         droptable("dbo.products");     } } 

result:

create table [dbo].[products] (     [id]    uniqueidentifier not null,     [price] int              not null,     constraint [pk_dbo.products] primary key nonclustered ([id] asc) );  go create clustered index [ix_price]     on [dbo].[products]([price] asc); 

Comments