title: Entity Framework Core 2.0 autoincrement and primary key mapping
body: <p>I am working on converting a database-first project to code-first. </p>
  
  <p>I have the following class and I am using EF Core 2.0:</p>
  
  <pre><code>public class WorkUser
  {
      public int WorkUserId { get; set; }
  
      public int UserId { get; set; }
  }
  </code></pre>
  
  <p>I tried the following and not sure whether it is correct.</p>
  
  <pre><code>public class WorkUser
  {
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int WorkUserId { get; set; }
  
      [Key]
      public int UserId { get; set; }
  }
  </code></pre>
  
  <p>I want the <code>WorkUserId</code> as an autoincrement property and <code>UserId</code> as primary key. The <code>UserId</code> value is coming from another table. So want this to be primary key but without autoincrement.</p>
  
  <p>How to achieve this?</p>