title: Why am I getting a dictionary error in from my partial view in my MVC Application?
body: <p>I have an edit view on my MVC web app that has some partial views in it.  The purpose of the partial views is to allow a user to add data to a dropdown list that is perhaps missing.  The partial views work on the <code>create</code> view but not the <code>edit</code> view.  When you try to edit a car the parial view throws an error of:</p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type
    'MyProject.Models.Car', but this dictionary requires a model item
    of type 'MyProject.Models.Manufacturer'.</p>
  </blockquote>
  
  <p>Here is a snapshot of my code.  I'm using Ajax forms for everything I do here.</p>
  
  <p><strong>Edit</strong></p>
  
  <pre><code>@model MyProject.Models.Car
  
  @using (Ajax.BeginForm("Edit", "Car", new AjaxOptions { 
      HttpMethod = "POST", 
      OnSuccess = "success" }))
  {
      @Html.AntiForgeryToken()
      @Html.ValidationSummary()
  
      ...form fields etc
  }
  @Html.Partial("_Manufacturer")
  </code></pre>
  
  <p><strong>_Manufacturer (partial view)</strong></p>
  
  <pre><code>@model MyProject.Models.Manufacturer
   @using (Ajax.BeginForm("Create", "Manufacturer", new AjaxOptions { 
      HttpMethod = "POST", 
      OnSuccess = "success" }))
  {
      @Html.AntiForgeryToken()
      @Html.ValidationSummary()
  
      ...form fields etc
  }
  </code></pre>
  
  <p>As you can see, the edit view allows you to edit a car whilst the partial view, which is triggered as a modal (bootstrap 4.0), allows you to add manufacturers to one of the dropdown lists should they be missing.</p>
  
  <p>I'm not sure as to why this causes a dictionary error though, the <code>Manufacturer</code> model is defined in the partial view and so shouldn't be using the <code>Car</code> model.  Is this related to the fact we are editing a specific record and therefore pass an ID as a parameter?</p>