Hi,
How to get the Last inserted Id value form database using entity framework webAPI .
that has id as primary key and is a identity
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
kamal15 reputationPosted Nov 30, 2016, 8:44 PM EST
SanthoshRank #5,917 · 282 reputationPosted Nov 30, 2016, 9:03 PM EST
SanthoshRank #5,917 · 282 reputationPosted Dec 8, 2016, 12:21 AM EST
Harshal PatilRank #9,687 · 203 reputationPosted Dec 8, 2016, 2:24 AM EST
int lastid = entity.tblLocations.Max(p => p.id);var datainsert = new Customer() { Name = "Steven" };context.AddObject(customer);context.SaveChanges();var id = customer.Id;Brijesh RathorRank #7,391 · 242 reputationPosted Dec 8, 2016, 3:08 AM EST
Hope this will help you.