ef code first - Why does EF drop and create the same index? -


i have existing index (ix_itemimportsummaryid) generated foreignkey on itemimportsummary because default index naming structure. if try explicitly create index same name on id field, drop index , create again in migration script.

the funny thing is, if give non-default name instead, rename index rather drop create it. seems ef stupid in scenario , doesn't realize can not @ all.

public class itemimportsummarydetail {     public int id { get; set; }      [foreignkey("itemimportsummaryid")]     public virtual itemimportsummary itemimportsummary { get; set; }      [index("ix_itemimportsummaryid", isunique = false)]     [index("ix_mpbid", 2, isunique = true)]     public int itemimportsummaryid { get; set; }      [required]     [stringlength(maximumlength:10)]     [index("ix_mpbid", 1, isunique = true)]     public string mpbid { get; set; } } 

this add-migration generates:

dropindex("dbo.itemimportsummarydetails", new[] { "itemimportsummaryid" }); createindex("dbo.itemimportsummarydetails", "itemimportsummaryid"); 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -