title: Existing Database Indentity Column MVC 4
body: <p>I am using an existing database to create an Project Reporting System. And I want the Primary Key, which is the Project id value of the project table to be automatically created and it is not setting a new value, as I have to input the Id, but I don't want the user to do that. Can anyone help me with this problem please?</p>
  
  <p>Patrick</p>
  
  <p><strong>Controller</strong>
  `        //
          // GET: /Project/Create</p>
  
  <pre><code>    public ActionResult Create()
      {
          ViewBag.Status = new SelectList(db.pjt_Statuses, "pjt_Status_ID", "StatusName");
          ViewBag.SubCategoryID = new SelectList(db.pjt_SubCategories, "pjt_SubCat_ID", "SubCatName");
          return View();
      }
  
      //
      // POST: /Project/Create
  
      [HttpPost]
      public ActionResult Create(pjt_Projects pjt_projects)
      {
          if (ModelState.IsValid)
          {
              pjt_projects.CreationDate = DateTime.Now;
              db.pjt_Projects.Add(pjt_projects);
              db.SaveChanges();
              return RedirectToAction("Index");
          }
  
          ViewBag.Status = new SelectList(db.pjt_Statuses, "pjt_Status_ID", "StatusName", pjt_projects.Status);
          ViewBag.SubCategoryID = new SelectList(db.pjt_SubCategories, "pjt_SubCat_ID", "SubCatName", pjt_projects.SubCategoryID);
          return View(pjt_projects);
      }`
  </code></pre>
  
  <p><strong>Database Table Script</strong></p>
  
  <pre><code>`CREATE TABLE [dbo].[pjt_Projects](
  [Pjt_Id] [int] IDENTITY(1,1) NOT NULL,
  [ProjectName] [nchar](100) NULL,
  [Status] [int] NULL,
  [Start_Date] [date] NULL,
  [Estimated_End_Date] [date] NULL,
  [Documents] [nvarchar](max) NULL,
  [Notes] [nvarchar](max) NULL,
  [Budget] [smallmoney] NULL,
  [Current_Spending] [smallmoney] NULL,
  [ProjectOwner] [nvarchar](50) NULL,
  [Active] [bit] NULL,
  [Actual_End_date] [date] NULL,
  [CreationDate] [date] NULL,
  [CreatedByEmpNo] [nchar](10) NULL,
  [UpdateDate] [date] NULL,
  [UpdatedByEmpNo] [nchar](10) NULL,
  [SubCategoryID] [int] NULL,`
  
  
  **Generate Context Db Code**
      public int Pjt_Id { get; set; }
      public string ProjectName { get; set; }
      public Nullable&lt;int&gt; Status { get; set; }
      public Nullable&lt;System.DateTime&gt; Start_Date { get; set; }
      public Nullable&lt;System.DateTime&gt; Estimated_End_Date { get; set; }
      public string Documents { get; set; }
      public string Notes { get; set; }
      public Nullable&lt;decimal&gt; Budget { get; set; }
      public Nullable&lt;decimal&gt; Current_Spending { get; set; }
      public string ProjectOwner { get; set; }
      public Nullable&lt;bool&gt; Active { get; set; }
      public Nullable&lt;System.DateTime&gt; Actual_End_date { get; set; }
      public Nullable&lt;System.DateTime&gt; CreationDate { get; set; }
      public string CreatedByEmpNo { get; set; }
      public Nullable&lt;System.DateTime&gt; UpdateDate { get; set; }
      public string UpdatedByEmpNo { get; set; }
      public Nullable&lt;int&gt; SubCategoryID { get; set; }    
  </code></pre>