title: view model in mvc4 showing errors
body: <p>I have a mvc4 application.Where users can create new projects and add comments on each project. ( I cant work out the comment adding part)</p>
  
  <p>I have two models
  1.Comment</p>
  
  <pre><code>public partial class Comment
      {
          public int CommentID { get; set; }
          public string Title { get; set; }
          public int ProjectID { get; set; }
          public string Rating { get; set; }
  
          public virtual Project Project { get; set; }
      }
  </code></pre>
  
  <p>2.Project</p>
  
  <pre><code>public partial class Project
      {
          public Project()
          {
              this.Comments = new HashSet&lt;Comment&gt;();
          }
  
          public int ProjectID { get; set; }
          public string Name { get; set; }
          public string Goal { get; set; }
  
          public virtual ICollection&lt;Comment&gt; Comments { get; set; }
      }
  </code></pre>
  
  <p>Now I want to display the following action links on project controllers index page :
  Edit | Details | Delete | Add Comment
  (The edit,details and delete functionalities are working fine but cant create comments)</p>
  
  <p>This is my project controller :</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data;
  using System.Data.Entity;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using ProjectCreation.Models;
  
  namespace ProjectCreation.Controllers
  {
      public class ProjectController : Controller
      {
          private ProjectCreationEntities db = new ProjectCreationEntities();
  
          //
          // GET: /Project/
  
          public ActionResult Index()
          {
              return View(db.Projects.ToList());
  
  
          }
  
          //
          // GET: /Project/Details/5
  
          public ActionResult Details(int id = 0)
          {
              Project project = db.Projects.Find(id);
              if (project == null)
              {
                  return HttpNotFound();
              }
              return View(project);
          }
  
  
          //
          // GET: /Project/Create
  
          public ActionResult Create()
          {
              return View();
          }
  
          //
          // POST: /Project/Create
  
          [HttpPost]
          public ActionResult Create(Project project)
          {
              if (ModelState.IsValid)
              {
                  db.Projects.Add(project);
                  db.SaveChanges();
                  return RedirectToAction("Index");
              }
  
              return View(project);
          }
  
          //
          // GET: /Project/Edit/5
  
          public ActionResult Edit(int id = 0)
          {
              Project project = db.Projects.Find(id);
              if (project == null)
              {
                  return HttpNotFound();
              }
              return View(project);
          }
  
          //
          // POST: /Project/Edit/5
  
          [HttpPost]
          public ActionResult Edit(Project project)
          {
              if (ModelState.IsValid)
              {
                  db.Entry(project).State = EntityState.Modified;
                  db.SaveChanges();
                  return RedirectToAction("Index");
              }
              return View(project);
          }
  
          //
          // GET: /Project/Delete/5
  
          public ActionResult Delete(int id = 0)
          {
              Project project = db.Projects.Find(id);
              if (project == null)
              {
                  return HttpNotFound();
              }
              return View(project);
          }
  
          //
          // POST: /Project/Delete/5
  
          [HttpPost, ActionName("Delete")]
          public ActionResult DeleteConfirmed(int id)
          {
              Project project = db.Projects.Find(id);
              db.Projects.Remove(project);
              db.SaveChanges();
              return RedirectToAction("Index");
          }
  
          protected override void Dispose(bool disposing)
          {
              db.Dispose();
              base.Dispose(disposing);
          }
  
        **  public ActionResult Comment(int id = 0)
          {
              Comment comment = db.Comments.Find(id);
  
              if (comment == null)
              {
                  return HttpNotFound();
              }
              return View(comment);
          }
  
          [HttpPost]
          public ActionResult Comment(Comment comment)
          {
              if (ModelState.IsValid)
              {
                  db.Comments.Add(comment);
                  db.SaveChanges();
                  return RedirectToAction("Index");
              }
  
              return View(comment);
          } **
      }
  }
  </code></pre>
  
  <p>I somehow cant create a comment on clicking on the "Add Comment link ". Rest of the project controller is working fine. 
  This is my comment controller action's view page :</p>
  
  <pre><code>@model ProjectCreation.Models.Comment
  
  @{
      ViewBag.Title = "Comment";
  }
  
  &lt;h2&gt;Comment&lt;/h2&gt;
  
  @using (Html.BeginForm()) {
      @Html.ValidationSummary(true)
  
      &lt;fieldset&gt;
          &lt;legend&gt;Comment&lt;/legend&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Title)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.Title)
              @Html.ValidationMessageFor(model =&gt; model.Title)
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.ProjectID)
          &lt;/div&gt;
          &lt;div class="editor-label"&gt;
              @Html.EditorFor(model =&gt; model.ProjectID)
  
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Rating)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.Rating)
              @Html.ValidationMessageFor(model =&gt; model.Rating)
          &lt;/div&gt;
  
          &lt;p&gt;
              &lt;input type="submit" value="Create" /&gt;
          &lt;/p&gt;
      &lt;/fieldset&gt;
  }
  
  &lt;div&gt;
      @Html.ActionLink("Back to List", "Index")
  &lt;/div&gt;
  
  @section Scripts {
      @Scripts.Render("~/bundles/jqueryval")
  }
  </code></pre>
  
  <p>Can someone please guide me .I m passing the project id accurately.I cant seem to create a new comment.The view page is opened but nothing is updated. It even shows a drop down for project id instead of label.</p>