2

I have a need to set the every first value in a auto increment id field to a value different to 1 is there a way to do that ?

Is it just a matter of doing a

DBCC CHECKIDENT(<table_name>, RESEED, 1001)

in the Context initialization within the Seed method ?

I've tried this method but it does not work, is there something else I can try.

PS: i know how to use seeded sql statements, its getting this particular functionality to work im having trouble with im trying to work out, ie. reseed the identity column to 1001 in this case. On my table im trying to set in identity seed value to 1001

Mark
  • 2,454
  • 4
  • 26
  • 29
  • http://stackoverflow.com/questions/6312336/how-can-i-get-my-database-to-seed-using-entity-framework-codefirst – Dave Alperovich Jan 30 '13 at 06:58
  • Thanks dave i know how to seed data problem is the increment value is not working have elaborated on my question after some further investigation – Mark Jan 30 '13 at 07:04
  • I'd suggest that you're doing something wrong if you have *any* requirements about identity values. They should be treated as opaque blobs. You shouldn't care about their numerical value, their order, whether there are gaps, etc. – Damien_The_Unbeliever Jan 30 '13 at 07:19
  • There is always exceptions in life, unfortunately this is one of them, and in this case starting at 1 is not an option. I was hoping for an easy EF answer, but otherwise if not, we need to create a SQL Script for installation into PROD anyway so its just a matter of changing the seed value to start at a higher id than the old system we are replacing, looks like i'll just manually set the seed value in the table create script. All good in the end. – Mark Jan 30 '13 at 13:14

0 Answers0