title: Table 'tblCustomer' does not have the identity property. Cannot perform SET operation
body: <p>Occurs when I try to set the identity_insert to ON in the SQL DATAMANAGEMENT STUDIO.</p>
  
  <p>The worst is I do not know why should I deal with this value, and I am not even sure that the following code hits more than the copy of the database in the local memory.</p>
  
  <p>I have got this message previously, when the debug hits the SaveChanges line : 
  "Cannot insert explicit value for identity column in table 'tblCustomer' when IDENTITY_INSERT is set to OFF"</p>
  
  <pre><code>    ` public ActionResult Submit( 
      Customer obj) //validation runs 
      { 
  
          if (ModelState.IsValid)
          {
              CustomerDal Dal = new CustomerDal();
              Dal.Customer.Add(obj);     //in memory
              Dal.SaveChanges();          //physical commit 
  
              return View("Customer", obj);
          }
          else
          { 
              return View("EnterCustomer", obj);
          }
      }`
  
      public class Customer
  {
      [Key]
      [Required]
      [DatabaseGenerated(DatabaseGeneratedOption.none)]
      public string CustomerCode { get; set; }
  
      [Required]
      [StringLength(10)]
      [RegularExpression("^[A-Z]{7,7}$")]
      public string CustomerName { get; set; }
  }
  
      public class CustomerDal : DbContext 
  {
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
          modelBuilder.Entity&lt;Customer&gt;().ToTable("tblCustomer");
      }
  
      public DbSet&lt;Customer&gt; Customer { get; set; }
  
  }
  </code></pre>
  
  <p><code>CREATE TABLE [dbo].[tblCustomer](</code>
   <code>[CustomerCode] [varchar](50) NOT NULL,</code>
   <code>[CustomerName] [varchar](50) NULL,</code>
   <code>CONSTRAINT [PK_tblCustomer] PRIMARY KEY CLUSTERED</code>
   <code>(</code>
   <code>[CustomerCode] ASC</code>
   <code>)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,</code>
   <code>IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)</code>
   <code>ON [PRIMARY]</code>
   <code>) ON [PRIMARY]</code></p>
  
  <pre><code>    @using (Html.BeginForm("Submit", "Customer", FormMethod.Post))
      {
  
          &lt;i&gt;Customer Name : &lt;/i&gt; @Html.TextBoxFor(m =&gt; m.CustomerName)
  
      &lt;br&gt;
      @Html.ValidationMessageFor(x =&gt; x.CustomerName)
      &lt;br&gt;
  
          &lt;i&gt;Customer Code : &lt;/i&gt; @Html.TextBoxFor(m =&gt; m.CustomerCode)
  
              &lt;br&gt;
              @Html.ValidationMessageFor(x =&gt; x.CustomerCode)
              &lt;br&gt;
              &lt;input id = "Submit1" type = "submit" value = "submit"/&gt;
  
              }
  </code></pre>