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