get last id entity framework code example
Example 1: get last id ef
//Grab the highest value using the Max() method
int max = db.Products.Max(p => p.ID);
Example 2: get last id ef
//Grab the highest ID value using the OrderByDescending() method
var max = db.Products.OrderByDescending(p => p.ID).FirstOrDefault().ID;