C
C#3y ago
Larsa

❔ Database ID not beginning from 1?

Hello all, complete noob to .NET here. I have successfully seeded my database with some data in ASP.NET MVC application but finding that the ID for each model in the SQL database is beginning from 5 and not 1? This is the case for all 3 of my models. I've done quite a bit of googling - checked the identity specification in SQL Server Manager which is fine. Any guidance is appreciated, cheers.
8 Replies
IcyPhoenix
IcyPhoenix3y ago
it shouldn't matter you can however reseed it if you really want to you are probably deleting rows and re-inserting them or something along those lines what you can try to do is do a migration then insert a row see if its id 1 or not
Larsa
LarsaOP3y ago
Ok, I was concerned I had some other data there - which is not the case Ok I might try another migration
IcyPhoenix
IcyPhoenix3y ago
the id always goes up never resets unless you kill the table (or if you truncate the table)
Larsa
LarsaOP3y ago
Each time I run my application - all 3 model have ID starting from 5 If it's not going to affect much then that's ok
IcyPhoenix
IcyPhoenix3y ago
the id doesn't matter atleast it shouldn't matter if you are for some reason coding assuming your ids will always be sequential thats a problem the only thing you should care about in id's is if they are unique - which pks are forced to be
Larsa
LarsaOP3y ago
Yep ok cool 👍 thanks for your help, appreciate it
M B V R K
M B V R K3y ago
If you set that column as an Identity Column the SQL Server will give you a choice to set the Increment operator which is by default 1, and the Seed Value which is too by default is 1 Check if the seed value doesn't contains 5 also there is a bit of details about how sql server dealing with this kind of columns I will explain it later
Accord
Accord3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server