I realize this must be a relatively simple thing to do, but I'm not getting what I'm looking for with Google.
I need to get the record ID of the record I just saved using the Entity Framework. With SQL queries we used "Select @@IDENTITY as 'Identity';"
If anyone can help it would be greatly appreciated.
The default behavior of Entity Framework is it sets identity fields on entities from the database right after
SaveChanges
is called.In the following sample code, before
SaveChanges
is called, my employee has a default ID of 0. AfterSaveChanges
my employee has a generated ID of 1.