title: Insert and list data in onew View
body: <p>What I am trying to do is to have one page to create new House and also diplsay all existing houses.
  the code for the main view is :</p>
  
  <pre><code>@modelData.Models.SGHouse
  
  @{
      ViewBag.Title = "";
  }
  
  &lt;h2&gt;Create&lt;/h2&gt;
  
  
  @using (Ajax.BeginForm(new AjaxOptions
                                        {
                                          HttpMethod = "Post",
                                          InsertionMode = InsertionMode.Replace,
                                          UpdateTargetId = "HouseList"
                                      }))
          {
              @Html.AntiForgeryToken()
  
              &lt;div class="form-horizontal"&gt;
          &lt;h4&gt;SGHouse&lt;/h4&gt;
          &lt;hr /&gt;
          @Html.ValidationSummary(true, "", new { @class = "text-danger" })
          @*&lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model._id, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model._id, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model._id, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;*@
  
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.House, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.House, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.House, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              &lt;div class="col-md-offset-2 col-md-10"&gt;
                  &lt;input type="submit" value="Create" class="btn btn-default" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  }
  @Html.Partial("_Houses",Model)
  </code></pre>
  
  <p>The code for my Partial view to list all houses is :</p>
  
  <pre><code>@model IEnumerable&lt;Data.Models.SGHouse&gt;
  &lt;div id="HouseList"&gt;
  
      &lt;table class="table"&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  @Html.DisplayNameFor(model =&gt; model.House)
              &lt;/th&gt;
              &lt;th&gt;&lt;/th&gt;
          &lt;/tr&gt;
  
          @foreach (var item in Model)
          {
              &lt;tr&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.House)
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.ActionLink("Edit", "Edit", new { id = item._id }) |
                      @Html.ActionLink("Details", "Details", new { id = item._id }) |
                      @Html.ActionLink("Delete", "Delete", new { id = item._id })
                  &lt;/td&gt;
              &lt;/tr&gt;
          }
  
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am not sure what view to return from my controller, if I do :</p>
  
  <pre><code>public ActionResult Create()
              {
                  return View();
              }
  </code></pre>
  
  <p>I get error from my partial view about model is null. 
  If I use :</p>
  
  <pre><code>public ActionResult Create()
                  {
                      return View(new SGHouse());
                  }
  </code></pre>
  
  <p>Then I get error </p>
  
  <p>The model item passed into the dictionary is of type 'Data.Models.SGHouse', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Data.Models.SGHouse]'.</p>
  
  <p>Any help how to resolve this.</p>
  
  <p>Thanks</p>