2
Answers

How to get identity column value .net core using linq

Rameez Javed

Rameez Javed

4y
1.7k
1
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)