title: Violation of PRIMARY KEY constraint . Cannot insert duplicate key
body: <p>I am quite new to ASP.Net MVC. I have just started learning it so kindly help me as I am stuck at a place. Early response will be highly appreciated.
  I am making a registration page. 
  Added a SQL database using App_data .Below is the table definition :</p>
  
  <pre><code>CREATE TABLE [dbo].[RegisterModel]
  (
      [Id] INT NOT NULL primary key , 
      [UserName] VARCHAR(50) NOT NULL, 
      [Email] VARCHAR(50) NOT NULL, 
      [Password] VARCHAR(50) NOT NULL, 
      [ConfirmPassword ] VARCHAR(50) NOT NULL,
  
  )
  </code></pre>
  
  <p>Then added ADO.Net Entity data model for the same.
  then I created a controller Account with an action method Index as below:</p>
  
  <pre><code>public class AccountController : Controller
      {
          //
          // GET: /Account/
      public ActionResult Index()
      {
          //using (dbRegisterModelEntities dc = new dbRegisterModelEntities())
          //{
              return View();
  
          }
  
      [HttpPost]
      public ActionResult Index(RegisterModel user)
      {
          if (ModelState.IsValid)
          {
              using (dbRegisterModelEntities dc = new dbRegisterModelEntities())
              {
                  dc.RegisterModels.Add(user);
                  dc.SaveChanges();
                  return RedirectToAction("Index", "Account");
  
              }
          }
            return View(user);
  
        }
  </code></pre>
  
  <p>After creating one user , now I am getting error : </p>
  
  <blockquote>
    <p>Violation of PRIMARY KEY constraint 'PK__tmp_ms_x__3214EC0778D493BE'.
    Cannot insert duplicate key in object 'dbo.RegisterModel'. The
    duplicate key value is (0). The statement has been terminated.</p>
  </blockquote>
  
  <p>This error is coming when I am trying to add a second user.</p>