title: Define foreign key for ICollection in Entity Framework model
body: <p>How to define in <code>Entity Framework 6</code>, which columns will be used to reference data in an <code>ICollection&lt;&gt;</code>?</p>
  
  <p>For example, we have a simple User-Information relation, were i can get all information from a user which updated or created the information:</p>
  
  <pre><code>public class User
  {
      public int UserId
      {
          get;
          get;
      }
  
      // Here is the problem, how to define that EF
      // Has to use the CreateUser column
      public virtual ICollection&lt;User&gt; User_CreateUser
      {
          get;
          set;
      }   
  
      // Here is the problem, how to define that EF
      // Has to use the UpdateUser column
      public virtual ICollection&lt;User&gt; User_UpdateUser
      {
          get;
          set;
      }   
  }
  
  public class Information
  {
      public int InfoId
      {
          get;
          set;            
      }   
  
      public int CreateUser
      {
          get;
          set;            
      }
  
      public int UpdateUser
      {
          get;
          set;            
      }
  
      [System.ComponentModel.DataAnnotations.Schema.ForeignKey("CreateUser")]
      public virtual User User_CreateUser
      {
          get;
          set;
      }
  
      [System.ComponentModel.DataAnnotations.Schema.ForeignKey("UpdateUser")]
      public virtual User User_UpdateUser
      {
          get;
          set;
      }       
  }   
  </code></pre>
  
  <p>But i don't know, how to map this. For the simple foreign-keys it was easy over annotations.</p>
  
  <p>I use database first but generating the models on my own. (Which works pretty good besides the <code>ICollection&lt;&gt;</code>.</p>
  
  <p>Thank you!</p>