title: Entity Framework Code First - using UserId key of Memberships/Users table as Foreignkey in a custom table
body: <p>I am trying to create a <code>SQL</code> table to include additional user information.
  I want it to be created by Migrations in VS2012 <code>(package console =&gt; update-database)</code>.</p>
  
  <p>I see that there are two tables using UserId column as key: <code>Memberships and Users tables.</code></p>
  
  <p>I am trying to define the following class and map it to SQL table via Migrator:</p>
  
  <pre><code>    [Key]
      [Column(Order = 0)]
      [ForeignKey("User")]
      public Guid **UserId** { get; set; }
  
      [Key]
      [Column(Order = 1)]
      [ForeignKey("Category")]
      public int CategoryId { get; set; }
  
      public virtual Category Category { get; set; }
      **public virtual User User { get; set; }**
  </code></pre>
  
  <p>Although it is obvious in the Users SQL table that UserId column is the key, I get this error message:</p>
  
  <pre><code>\tSystem.Data.Entity.Edm.EdmEntityType: : EntityType 'User' has no key defined. Define the key for this EntityType.
  \tSystem.Data.Entity.Edm.EdmEntitySet: EntityType: EntitySet 'Users' is based on type 'User' that has no keys defined.
  </code></pre>
  
  <p>What I am missing here? Might be that <code>Microsoft.VisualBasic.ApplicationServices.User / System.Web.Security.MembershipUser</code> classes weren't necessarily mapped to the tables this way and vise versa, and therefore the <code>UserId</code> property is not declared is Key dataannotation?</p>
  
  <p>I am open for other solutions for this problem.</p>
  
  <p>Big Thanks!</p>