title: Entity Framework Code First Foreign Key adding Index as well
body: <p>I have simple table definition in EF 6 code-first with simple foreign key.</p>
  
  <pre><code>public class Address
  {
          /// &lt;summary&gt;
          /// Gets or sets the id.
          /// &lt;/summary&gt;
          [Key]
          [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
          [Column(Order = 1)]
          public int Id { get; set; }
  
           /// &lt;summary&gt;
          /// Gets or sets the town.
          /// &lt;/summary&gt;
          public virtual Town Town { get; set; }
  
          /// &lt;summary&gt;
          /// Gets or sets the paf address town id.
          /// &lt;/summary&gt;
          [Column(Order = 2)]
          public int TownId { get; set; }
  }
  </code></pre>
  
  <p>When the table is created it is creating a foreign key as well as an index. I wonder why, because such index is usually very inefficient, and for big databases it causing a lot of issues. So why it created that index instead of foreign key only. And how to disable by default such index creating.</p>