title: Entity Framework Code First : how to annotate a foreign key for a "Default" value?
body: <p>I have 2 classes: Client and Survey.</p>
  
  <p>Each Client can have many surveys - but only one default survey.</p>
  
  <p>I have defined the classes like this:</p>
  
  <pre><code>public class Client
  {
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int ID { get; set; }
  
      public string ClientName { get; set; }
  
      public Nullable&lt;int&gt; DefaultSurveyID { get; set; }
  
      [ForeignKey("DefaultSurveyID")]
      public virtual Survey DefaultSurvey { get; set; }
  
      public virtual ICollection&lt;Survey&gt; Surveys { get; set; }
  }
  
  public class Survey
  {
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int ID { get; set; }
  
      public string SurveyName { get; set; }
  
      [Required]
      public int ClientID { get; set; }
  
      [ForeignKey("ClientID")]
      public virtual Client Client { get; set; }
  }
  </code></pre>
  
  <p>This creates the Client table as I expect:</p>
  
  <pre><code>[dbo].[Clients]
  (
  [ID] [int] IDENTITY(1,1) NOT NULL,
  [ClientName] [nvarchar](max) NULL,
  [DefaultSurveyID] [int] NULL
  )
  </code></pre>
  
  <p>But the Survey table has an extra foreign key:</p>
  
  <pre><code>[dbo].[Surveys]
  (
  [ID] [int] IDENTITY(1,1) NOT NULL,
  [SurveyName] [nvarchar](max) NULL,
  [ClientID] [int] NOT NULL,
  [Client_ID] [int] NULL
  )
  </code></pre>
  
  <p>Why is Code First generating this relationship and how to I tell it not to?</p>