I use SQL Server 2017 (v14.0.2027.2) and EF Core 2.1.
After I added migration on this code:
public class TblTrack
{
public long Id { get; set; }
...
}
public class TblProduct
{
public long Id { get; set; }
...
}
public class TblProductItem
{
[Key]
[Required]
public long ProductId { get; set; }
[Key]
[Required]
public long TrackId { get; set; }
// Navigation properties
public TblProduct Product { get; set; }
public TblTrack Track { get; set; }
}
Ef Core creates only TrackId index
migrationBuilder.CreateIndex(
name: "IX_tbl_ProductItems_TrackId",
table: "tbl_ProductItems",
column: "TrackId");
Why was an index created for TrackId
but not for ProductId
?