title: Asp.net entity framework editing single model from enum doesn't savechanges in db
body: <p>So basically I have View where I pass whole enum of my models and it displays them and generates form for each one of them. The problem is that after submitting individual form it doesn't modify my model (it should add string to list of strings). After refresh everything goes back to as it was. I'am beginner so this might be pretty silly problem but I can't find answer becouse my situation is some what different what I find on the internet.</p>
  
  <p>Here's my code</p>
  
  <p>Model:</p>
  
  <pre><code> public class Post
      {
          [Key]
          public int PostID { get; set; }
  
          [DataType(DataType.ImageUrl)]
          public string PhotoPath {get; set; }
  
          [DisplayName("Description")]
          [DataType(DataType.MultilineText)]
          public string Description { get; set; }
  
          [DisplayName("Title")]
          [Required(ErrorMessage="Title is required")]    
          public string Title { get; set; }
  
          [Display(Name = "Comments")]
          public List&lt;string&gt; Comments = new List&lt;string&gt;();
      }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>  [HttpPost]
      public ActionResult Index(int? id) 
      {
          string comment = Request.Form["comment-text"];
          Post post = db.Images.Find(id);
  
          if (!String.IsNullOrEmpty(comment) &amp;&amp; post != null)
          {
  
                      post.Comments.Add(comment);
                      db.Entry(post).State = EntityState.Modified;
                      db.SaveChanges();
  
          }
          return View(db.Images.ToList());
      }
  </code></pre>
  
  <p>And that's my view and I think that's poorly made becouse I can't post single model out of enum instead it gives me back whole enum to controller</p>
  
  <pre><code>&lt;div class="posts-section"&gt;
      @foreach (var item in Model)
      {
          &lt;div class="single-post col-lg-4"&gt;
              &lt;h3&gt;@Html.DisplayFor(modelItem =&gt; item.Title)&lt;/h3&gt;
              &lt;img src="@item.PhotoPath" style="width:128px;height:128px" /&gt;
              &lt;p&gt;@Html.DisplayFor(modelItem =&gt; item.Description)&lt;/p&gt;
              &lt;div class="comments"&gt;
                  @using (Html.BeginForm("Index", "Home", FormMethod.Post))
                  {
                      &lt;input id="id" name="id" type="hidden" value="@item.PostID"&gt;
                      @Html.LabelFor(modelItem =&gt; item.Comments, new { @class = "col-sm-4 control-label" })
                      &lt;div class="col-sm-4"&gt;
                          &lt;input type="text" class="form-control" id="@item.PostID" name="comment-text" placeholder="Write you comment here"&gt;
                          &lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt;
                      &lt;/div&gt;
                  }
  
                  @foreach (string comment in item.Comments)
                  {
                      &lt;div class="single-comment"&gt;
                          &lt;p&gt;@comment&lt;/p&gt;
                      &lt;/div&gt;
                  }
              &lt;/div&gt;
          &lt;/div&gt;
      }
  &lt;/div&gt;
  </code></pre>
  
  <p>All I would want to do is get value from input(comment-text) and add that value to particular model's list. My problem is that db.find gets model but it doesn't change it's value becouse after refresh everything disapears</p>