When I am passing the values using post method in postman, Id is passing as 0 everytime, where id is the primary key in my database table.
Here is my model :
public class WoodlandDataModel
{
public int id { get; set; }
public string cph_id { get; set; }
public int subactivity_id { get; set; }
}
And Given below is my controller:
public IHttpActionResult Post(WoodlandDataModel data)
{
if (!ModelState.IsValid)
return BadRequest("Invalid data.");
using (var entity = new WoodlandDB_Entities())
{
entity.tbl_woodland_details.Add(new tbl_woodland_details()
{
cph_id = data.cph_id,
subactivity_id = data.subactivity_id
});
entity.SaveChanges();
}
return Ok();
}
I want that when I will pass any value, id will be auto increment in the database.
Can somebody help me to find out the solution.
Any help will be highly appreciated!
Rutuparna Panda
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…