0

I have been searching around for a way to set the start seed value on an identity property in my table. If I insert something in the table with the property configured like it is below the id column will start with the value 1. However I would like it to start with the value 1000 or perhaps 10000. Is this possible with a code first approach? Can this be set with DataAnnotations or in an EntityTypeConfiguration class?

My identity property looks like this:

[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int OrderNumber { get; set; }

Is this is only possible in the table designer, column properties in Visual Studio when the table is already created?

Any help would be much appreciated.

Dux
  • 31
  • 4
  • 2
    dup of http://stackoverflow.com/questions/11255263/dataannotations-set-identity-seed-value-on-primary-key-with-code-first – dotNET Jan 20 '14 at 14:55
  • If you care about the numeric value of identity columns, you're probably using them wrong. You ought to treat them as opaque blobs that you happen to be able to store in `int`s, and should certainly never show them to the end users. – Damien_The_Unbeliever Jan 20 '14 at 14:57
  • Our order numbers is used to track orders in another system so I indeed need to show them to the user. Do you have a suggestion on another approach to create order numbers that uniquely identifies an order? Thanks – Dux Jan 20 '14 at 15:06

0 Answers0