title: MVC4 / EF5 / Auto Increment
body: <p>I'm not sure how to exactly word my question which is probably why I cannot find an example of this anywhere. I'm playing around with MVC4 &amp; EF5 (Web API too) but I'm not sure how to proceed with the Model as I've never really had to do much with them before. I'm doing something around the Periodic Tablet of Elements and I want to make it so that I have a list built for an element with it's electron configuration. However, I'd like to have it just auto number based on the input order. How can I tell EF to auto-increment a field? Basically like a primary key field without that limitation behind it. Here's what I have so far - I'm just not sure how to proceed:</p>
  
  <pre><code>public class Elements
  {
      public int ElementID { get; set; }
      public string Name { get; set; }
      public int AtomicNumber { get; set; }
      public string Symbol { get; set; }
      public virtual Categories Category { get; set; }
      public virtual States State { get; set; }
      public virtual Occurences Occurence { get; set; }
      public virtual ICollection&lt;Configurations&gt; Configuration { get; set; }
  }
  
  public class Categories 
  {
      public int CategoryID { get; set; }
      public string CategoryName { get; set; }
  }
  
  public class States
  {
      public int StateID { get; set; }
      public string StateName { get; set; }
  }
  
  public class Occurences
  {
      public int OccurenceID { get; set; }
      public string OccurenceName { get; set; }
  }
  
  public class Configurations
  {
      public int ConfigurationID { get; set; }
      public int Order { get; set; }
      public int Value { get; set; }
  }
  </code></pre>
  
  <p>Looking above what I'd like is for anytime a value is added to Configurations.Order the value starts at 1 and increases with each new 'row' but only for that specific ElementID. </p>
  
  <p>Does that make sense? I was looking at using Data Annotations but I couldn't find anything that matched other than a Key Field but that'd make each Order a unique number - which I don't want. I feel like I'm not expressing this correctly because of all the stuff I've been looking at to figure it out, so here's a picture! yay!</p>
  
  <p><img src="https://i.stack.imgur.com/wCf8G.png" alt="enter image description here"></p>
  
  <p>This very well could be something that is better off from a programmatic standpoint. Even though this data changes once in a blue moon, I wanted to try and do it through EF if possible just so I know how.</p>
  
  <p>Thanks a ton in advance. Also, if you see any other glaring errors, by all means let me know :) I rarely get to work with this side of web dev so I'm sure there's ways to do things better.</p>