Below code snippet describes the generation of Identity value in the database from code behind in MVC.
Just modify your property in the Model as below,
public class myModel {
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int AutoId { get; set; }
}'DatabaseGeneratedAttribute' is used to generate the Identity value automatically into the database.
'[Key]' mentioned above is used to define the primary key of the table.