Auto generated ID when inserting into table using EF
Posted: Tue 09 Nov 2010 09:28
I am using dotConnect 5.7 to connect to our ORACLE database. We have a table with an auto-incremented ID column.
I add new rows to the table using code like
I would like to get my hands on the ID that was created in the new row in the table.
How do I do this? There are various posts on this forum asking similar questions, but none that I can find that use the entity model approach described here.
Essentially, I am looking for equivalant tothis post on MSDN entitled
"How to acquire the ID of last row inserted using Entity Framework"
I add new rows to the table using code like
Code: Select all
using (var entities = new MyEntityModel())
{
entities.MyMessageTable.AddObject(message);
insertResult = entities.SaveChanges();
}
How do I do this? There are various posts on this forum asking similar questions, but none that I can find that use the entity model approach described here.
Essentially, I am looking for equivalant tothis post on MSDN entitled
"How to acquire the ID of last row inserted using Entity Framework"