title: Identity column in EF 4
body: <p>I follow by entity framework example :</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/bb399182.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb399182.aspx</a></p>
  
  <p>and I have problem with Identity Columns.</p>
  
  <p>Here is part of code of creating database:</p>
  
  <pre><code>CREATE TABLE [dbo].[Person](
      [PersonID] [int] IDENTITY(1,1) NOT NULL,
      [LastName] [nvarchar](50) NOT NULL,
      [FirstName] [nvarchar](50) NOT NULL,
      [HireDate] [datetime] NULL,
      [EnrollmentDate] [datetime] NULL,
   CONSTRAINT [PK_School.Student] PRIMARY KEY CLUSTERED 
  (
      [PersonID] ASC
  )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
  ) ON [PRIMARY]
  END
  GO
  </code></pre>
  
  <p>In VS 2010 I build .edmx and at model I see that Person StoreGeneratedPattern  is set to Identity.</p>
  
  <p>But when I want to create Person, by :
  <img src="https://i.stack.imgur.com/x27f5.png" alt="alt text"></p>
  
  <p>Why I must put id, if this column is autoincrement?</p>
  
  <p>EDITŁ</p>
  
  <p>I thought that I found the way to resolve my problem by:</p>
  
  <pre><code>var schoolContext = new SchoolEntities();
  
              schoolContext.AddToPeople(new Person() { LastName = "Gates", FirstName = "Bil" });
  
              schoolContext.SaveChanges();
  </code></pre>
  
  <p>because it added Bill to persons, but...because PersonID is not nullable, and it inserted him with id 0. When I tried add another person the same way of course I get error about primary key :)</p>
  
  <p>So  still with nothing...</p>
  
  <p>Any ideas ?</p>