title: Adding int value to database giving error, yet string value works
body: <p>I am currently developing in an MVC project, using Entity framework, and SQL Express server.</p>
  
  <p>I am trying to add a user to a Users table. The user is currently compromised of the following:</p>
  
  <pre><code>CREATE TABLE [dbo].[Users] (
      [UserID] INT NOT NULL PRIMARY KEY,
      [Admin]  BIT NOT NULL,
  );
  </code></pre>
  
  <p>When I go through the function below to add into the above table:</p>
  
  <pre><code>[HttpPost]
  public String AddUser(List&lt;String&gt; values)
  {
      using (DataBASE db = new DataBASE())
      {
          Users newUser = new Users();
          newUser.UserID = Int32.Parse(values[0]); //There is correct data stored here as an int value
          newUser.Admin = Boolean.Parse(values[1]); //There is correct data stored here as an bool value
          db.Users.Add(newUser); //The newUser object is correct
          db.SaveChanges(); //The error occurs here
      }
      return "success";
  }
  </code></pre>
  
  <p>EDIT, this is the Users class requested (which is changed to a string whenever stored into the database):</p>
  
  <pre><code>[Table("Users")]
  public class Users
  {
      [Key]
      public int UserID { get; set;}
      public bool Admin { get; set; }
  }
  </code></pre>
  
  <p>I receive the following error:</p>
  
  <pre><code>"Cannot insert the value NULL into column UserID, table ‘…\\DATABASE.MDF.dbo.Users';
   column does not allow nulls. INSERT fails.\r\nThe statement has been terminated."}
  </code></pre>
  
  <p>The value is not NULL and the database is connecting correctly (as the delete function works properly and I when I break into the function the database connection is correct and the function is giving the correct data before updating by adding a new user.</p>
  
  <p>When I change the database to the following:</p>
  
  <pre><code>CREATE TABLE [dbo].[Users] (
      [UserID] NVARCHAR(50) NOT NULL PRIMARY KEY,
      [Admin]  BIT NOT NULL,
  );
  </code></pre>
  
  <p>And I add a user using the following function (changed the function above to where it doesn't pass an int but rather keeps the string value):</p>
  
  <pre><code>[HttpPost]
  public String AddUser(List&lt;String&gt; values)
  {
      using (DataBASE db = new DataBASE())
      {
          Users newUser = new Users();
          newUser.UserID = values[0]; //There is correct data stored here as an string value
          newUser.Admin = Boolean.Parse(values[1]); //There is correct data stored here as an bool value
          db.Users.Add(newUser); //The newUser object is correct
          db.SaveChanges(); //NO error occurs here
      }
      return "success";
  }
  </code></pre>
  
  <p>This is the Users class changed to a string to work for the string solution:</p>
  
  <pre><code>[Table("Users")]
  public class Users
  {
      [Key]
      public string UserID { get; set;}
      public bool Admin { get; set; }
  }
  </code></pre>
  
  <p>Is there something against using an INT value in the database that I do not know of?</p>