title: (0x80131904): Cannot insert the value NULL into colum
body: <p>I'm new to MVC, doing my first training project. Recently I have encountered exception while inserting data into table, seems like I can't find solution: </p>
  
  <p>First I have created table:</p>
  
  <pre><code>CREATE TABLE [dbo].[tblPC] 
  (
      [PCID]   INT           NOT NULL,
      [PCName] NVARCHAR (50) NOT NULL,
      [PCDate] DATETIME      NOT NULL
  )
  </code></pre>
  
  <p>then a model with attributes:</p>
  
  <pre><code>[Table("tblPC")]
  public class PC
  {
      [Required]
      public int PCID { get; set; }
      [Required]
      [StringLength(3)]
      [RegularExpression("^[a-z]{2,2}[0-9]{1,1}$")]
      public string PCName { get; set; }
      [Required]
      public DateTime PCDate { get; set; }
  }
  </code></pre>
  
  <p>and then my context class:</p>
  
  <pre><code>public class PC_DB_Context : DbContext
  {
      public DbSet&lt;PC&gt; PCs { get; set; }
  }
  </code></pre>
  
  <p>and an action:</p>
  
  <pre><code> public ActionResult Submit(PC obj)
   {
          if (ModelState.IsValid)
          {
              PC_DB_Context PCContext = new PC_DB_Context();
              PCContext.PCs.Add(obj);
              PCContext.SaveChanges();
              return View("PC", obj);
          }
          else 
          {
              return View("EnterPC", obj);
          }
  }
  </code></pre>
  
  <p>I just can't avoid exception: </p>
  
  <blockquote>
    <p>SqlException (0x80131904): Cannot insert the value NULL into column 'PCID', table 'MyDB.dbo.tblPC'; column does not allow nulls. INSERT fails.</p>
  </blockquote>
  
  <p>when I set identity flag on <code>PCID</code> to true and setup increment all works, but what if I don't want it ...</p>
  
  <p>And here is my cshtml:</p>
  
  <pre><code>&lt;body&gt;
      &lt;div&gt; 
  
          &lt;form action="submit" method="post"&gt;
              PC ID: &lt;input name="PCID" type="number" value="@Model.PCID" /&gt;  @Html.ValidationMessageFor(x =&gt; x.PCID)&lt;br /&gt;
              PC Name: &lt;input name="PCName" type="text" value="@Model.PCName" /&gt;   @Html.ValidationMessageFor(x =&gt; x.PCName) &lt;br /&gt;
              PC Date: &lt;input name="PCDate" type="datetime" value="@DateTime.Now" /&gt;&lt;br /&gt;
              &lt;input id="Submit1" type="submit" value="submit" /&gt;&lt;br /&gt;
          &lt;/form&gt;
          &lt;br /&gt;
          @*@Html.ValidationSummary()*@
      &lt;/div&gt;
  &lt;/body&gt; 
  </code></pre>