Retrieve saved Entity Id

Either you’re saving an entity and then want to reference its primary-key or you want to use the Id to give a tracking number to the user you need the entity’s ID after it is being saved. This case happens when you set the “DatabaseGeneratedOption.Identity” attribute for the Model or in simple words the Id field is Auto-Number. Well retrieving the Entity’s Id after persistence using Entity Framework is not a complicated task but still beginners may not know it. It is easy just read the Id field of the object you have saved and that’s it you’ve got the ID.

Read 1091 times Last modified on Monday, 17 August 2015 08:10
Rate this item
(0 votes)
About Author
Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

Advanced Programming Concepts
News Letter

Subscribe our Email News Letter to get Instant Update at anytime