Rameez Javed

Rameez Javed

  • NA
  • 395
  • 61.5k

How to get identity column value .net core using linq

Aug 6 2020 2:21 AM
Hi, I have a table named Users with Primary Key UserId (auto Incremented by 1), I have 40 record and I've deleted all, now i want to get current identity value, I'm using following code but it gives me results as null. I should be 41 as I deleted 40 rows and now current Ident is 41, 
 
int? UsrId = _context.Users.Max(u => (int?)u.UserId);
 
Thanks in advance :) 

Answers (2)