title: increment field in entity framework depending on value of another field
body: <p>I'm new in Entity Framework and i have problem with something which was quite easy in pure t-sql. Assume that we have table with 3 columns. Id(identity, primary key), IdKind (int), Number(int). Column Nubmer depends on IdKind column. Data in this table should look like this:</p>
  
  <p>Id | IdKind | Number</p>
  
  <p>1 | 1      | 1</p>
  
  <p>2 | 1      | 2</p>
  
  <p>3 | 1      | 3</p>
  
  <p>4 | 2      | 1</p>
  
  <p>5 | 2      | 2</p>
  
  <p>6 | 2      | 3</p>
  
  <p>As you can see column number is auto incremented depends on IdKind. In t-sql I was finding max(Number) + 1 for some IdKind. Everything was in one stored procedure in one transaction so value of Number was unique for IdKind. </p>
  
  <p>How to accomplish the same in Entity Framework. Value of Number should be computed when creating new object or when changing IdKind.</p>