title: How to fix error "System.InvalidOperationException" in a partial view
body: <p>Hello I'm trying to add a database entry form into a modal that's on a page that displays info retrieved from my database, I've created a scaffold template using visual studios and it contains all the model information in it, I then put that into a partial view to display it through the model but I keep getting this error: </p>
  
  <pre><code>System.InvalidOperationException
  
  The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[TerminalHost.Models.buildingInfo]', but this dictionary requires a model item of type 'TerminalHost.Models.buildingInfo'"
  </code></pre>
  
  <p>Here is my homepage:</p>
  
  <pre><code>@model IEnumerable&lt;TerminalHost.Models.buildingInfo&gt;
  
  @{
  ViewBag.Title = "Home Page";
  }
  &lt;h3&gt;We suggest the following:&lt;/h3&gt;
  &lt;ol class="round"&gt;
  &lt;li class="one"&gt;
      &lt;h5&gt;Please begin creating your network structure:&lt;/h5&gt; 
      &lt;button id="modal-opener"&gt;Add a new building&lt;/button&gt;
  &lt;/li&gt;
  &lt;li class="two"&gt;
  
  &lt;/li&gt;
  &lt;/ol&gt;
  
  &lt;div class="Container"&gt;
  
      &lt;div class="Box1"&gt;
          @foreach (var item in Model)
          {&lt;div&gt;
              &lt;h4 class="Heading"&gt;@item.buildingName&lt;/h4&gt;
              &lt;h4 class="Heading"&gt;@item.buildingNumber&lt;/h4&gt;
              &lt;p&gt;@item.buildingDesc1&lt;/p&gt;
              &lt;p&gt;@item.buildingDesc2&lt;/p&gt;
              &lt;p&gt;@item.buildingDesc3&lt;/p&gt;
          &lt;/div&gt;
          }
      &lt;/div&gt;
      ....
  &lt;/div&gt;
  
  &lt;div id="Modal" title="Building Details"&gt;
  
  @Html.Partial("buildingForm")
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my Partial View:</p>
  
  <pre><code>@model TerminalHost.Models.buildingInfo
  
  @{
      ViewBag.Title = "Create";
  }
  
  &lt;h2&gt;Create&lt;/h2&gt;
  
  @using (Html.BeginForm())
  {
  @Html.AntiForgeryToken()
  @Html.ValidationSummary(true)
  
  &lt;fieldset&gt;
      &lt;legend&gt;buildingInfo&lt;/legend&gt;
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.buildingNumber)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.buildingNumber)
          @Html.ValidationMessageFor(model =&gt; model.buildingNumber)
      &lt;/div&gt;
      ....
      &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>Controller Action : </p>
  
  <pre><code>  public class HomeController : Controller
  {
      thDB _db = new thDB();
  
      public ActionResult building()
      {
          var buildingModel = _db.buildings.ToList().FirstOrDefault();
  
          return View(buildingModel);
      }
  
      public ActionResult buildingForm()
      {
          return PartialView();
      }
  }
  </code></pre>