Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Id's jumping up 1000 every time I build my app and insert a new record

I'm building a basic CRUD page following beginner asp.net-core-mvc/ef-core tutorials

I've been noticing every time I rebuild and create a new record through my mvc site my Id's jump up 1000

Example, currently the id's for my first few rows are:

  • 1, 2, 1002, 1003, 1004, 2002, 2003, 3002, 3003, 4002, 5002

How do I stop this? I've never seen this behavior before. From some googling it seems to be a sql 2012 issue however I'm not using sql 2012.

I'm using mssqllocaldb, everything's updated and I have SSMS2014 installed

like image 732
mejobloggs Avatar asked Sep 24 '16 02:09

mejobloggs


1 Answers

Even though you have installed the SSMS 2014, it doesn't install the 2014 local db instance. It still can be a SQL 2012 local DB. So my advice is to uninstall all old components and install the latest local db 2016 and SSMS 2016. Both are free.

Here are the links :

SQL Server 2016 Express LocalDB

SSMS 2016

Additional Note :

Yes this is a bug on the SQL server 2012.You can see it here :

Failover or Restart Results in Reseed of Identity

Workarounds :

If you need the Workarounds see the Workarounds tab on the above link.

enter image description here

Permanent solution :

If you need a permanent solution, you can use a higher version of SQL server. Like SQL server 2014 or 2016.You can select Free community editions of those.

like image 85
Sampath Avatar answered Nov 04 '22 20:11

Sampath