Reputation: 278
I made DB and Attach with Data entity Model in that I have table name Employee and primary key EMPID which autoincrement. And then I am adding Scaffolding Insert Update Delete automatic using entity framework.
So it always shows to enter EMPId also which is primary key and autoincrement too.
public partial class ProductCategory
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public string ProductDescription { get; set; }
public string ProductPrice { get; set; }
public Nullable<int> CategoryId { get; set; }
public virtual Category Category { get; set; }
}
This is my model class which automatic created by EF –
Upvotes: 1
Views: 205
Reputation: 71
Add this attributes on your primary key
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ProductId { get; set; }
Upvotes: 1