Header Ads

Acquire the ID of last inserted row using Entity Framework

Acquiring the ID of last inserted row (Primary and auto increment column) using Entity Framework is as follows:

 
Entities oEntities = new Entities();
tblSample ts = new tblSample();
ts.Description = "some Description Here!!!";
oEntities.InsertToSample(ts);
oEntities.SaveChanges();

lblMessage.Text = ts.SampleID;

No comments:

Powered by Blogger.