79187731

Date: 2024-11-14 07:27:43
Score: 1
Natty:
Report link

When you are performing "myDbContext.Users.Add(user);" Entity framework automatically added user object to primary key value as long value.

If you want to disable automatically value assigning use below way.

[Table("Users")]
public class UserModel
{
     [Key]
     [DatabaseGenerated(DatabaseGeneratedOption.None)] //--- Add this
     public long UserId { get; set; }
     public string EmailAddress { get; set; }
     public int  MemberId { get; set; }
     public string Password { get; set; }
}
Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): When you are
  • Low reputation (1):
Posted by: Tharuka Deshan