title: ViewModel base model is null on create action postback with MVC3
body: <p>I'm having some trouble getting my ViewModel to return a non-null object in the base model property in my controller's Create action postback. I currently have another page that is doing the exact same operations on another model that has almost the same properties and that form is working perfectly, so I feel like I'm missing something basic, though I can't place what is wrong.</p>
  
  <p>Here's my ViewModel with my Base class:</p>
  
  <pre><code>public class SystemFailureActionViewModel
  {
      /// &lt;summary&gt;
      /// View model class for adding and modifying SystemFailureActions
      /// &lt;/summary&gt;
      public SystemFailureAction action { get; set; }
  
      //properties
      public int TypeID { get; set; }
      public string TypeDescription { get; set; }
      public bool Assigned { get; set; } 
  
      public SystemFailureActionViewModel() { }
  
      public SystemFailureActionViewModel(SystemFailureAction action)
      {
          this.action = action;
      }
  
      //Collections for views
      public IEnumerable&lt;SelectListItem&gt; EditSystemFailiureTypesList { get { return ModelListProvider.FilteredSystemFailureTypeList; } }
      public IEnumerable&lt;SelectListItem&gt; DetailsSystemFailiureTypesList { get { return ModelListProvider.FullSystemFailureTypeList; } }
  }
  
  [MetadataType(typeof(SystemFailureActionMetadata))]
  public partial class SystemFailureAction
  {
      private class SystemFailureActionMetadata
      {
          /// &lt;summary&gt;
          /// ID for this failure action
          /// &lt;/summary&gt;
          public int ID { get; set; }
  
          /// &lt;summary&gt;
          /// Action Description
          /// &lt;/summary&gt;
          [Required]
          [StringLength(200)]
          [DisplayName("Action Description")]
          public string Description { get; set; }
      }
  }
  </code></pre>
  
  <p>Here's my Controller Add and Add Postback methods:</p>
  
  <pre><code>public ActionResult Add()
      {
          SystemFailureAction action = new SystemFailureAction();
          action.Description = "";
          populateSystemFailureActionData(action);
          return PartialView("Form", new SystemFailureActionViewModel(action));
      }
  
  
      [HttpPost]
      public ActionResult Add(SystemFailureActionViewModel viewModel, string[] selectedTypes, FormCollection collection)
      {
          SystemFailureAction newAction = viewModel.action;
  
          if (!ModelState.IsValid)
          {
              populateSystemFailureActionData(newAction);
              return PartialView("Form", new SystemFailureActionViewModel(newAction));
          }
  
          try
          {
              //Insert the new failure action type 
              context.SystemFailureActions.InsertOnSubmit(newAction);
              context.SubmitChanges();
  
              //Insert the failure type mappings
              updateSystemFailureAssociationData(newAction, selectedTypes);
              context.SubmitChanges();
  
              //Return the new data
              populateSystemFailureActionData(newAction);
              return PartialView("Done", new SystemFailureActionViewModel(newAction));
          }
          catch (Exception ex)
          {
              ModelState.AddModelError("", ex.Message);
              populateSystemFailureActionData(newAction);
              return PartialView("Form", new SystemFailureActionViewModel(newAction));
          }           
      }      
  </code></pre>
  
  <p>And finally here is my form, it is being loaded into a Jquery dialog and the postback is being done via Ajax.</p>
  
  <pre><code>  @using (Ajax.BeginForm(new AjaxOptions
  {
      HttpMethod = "Post",
      UpdateTargetId = "formDialog",
      InsertionMode = InsertionMode.Replace,
      OnSuccess = "onDialogDone()"
  }))
  {
      @Html.ValidationSummary(true)
      &lt;div&gt;
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.action.Description)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(model =&gt; model.action.Description)
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="categoryFieldSet"&gt;
          &lt;fieldset&gt;
              &lt;legend&gt;Mechanical System Failure Categories&lt;/legend&gt;
              &lt;div class="editor-field"&gt;
                  &lt;table&gt;
                      &lt;tr&gt;
                          @{
                              int count = 0;
                              List&lt;ManageMAT.ViewModels.SystemFailureActionViewModel&gt; types = ViewBag.Types;
  
                              foreach (var type in types)
                              {
                                  if (count++ % 3 == 0)
                                  {
                                      @: &lt;/tr&gt; &lt;tr&gt;
                                  }
                                  @: &lt;td&gt;
                                      &lt;input type="checkbox"
                                             id="selectedTypes + @type.TypeID"
                                             name="selectedTypes"
                                             value="@type.TypeID"
                                             @(Html.Raw(type.Assigned ? "checked=\"checked\"" : "")) /&gt;
                                      &lt;label for="selectedTypes + @type.TypeID"&gt;@type.TypeDescription&lt;/label&gt;
                                  @:&lt;/td&gt;
                              }
                          @:&lt;/tr&gt;
                          }
                  &lt;/table&gt;
              &lt;/div&gt;
          &lt;/fieldset&gt;
      &lt;/div&gt;
  }
  </code></pre>
  
  <p>If you're wondering what the ViewBag.Types logic is in the form it is related to <a href="https://stackoverflow.com/questions/8915750/generating-checkbox-lists-with-mvc3-using-a-complex-viewmodel-and-a-cross-table">this</a> question I asked earlier.</p>
  
  <p>Edit:</p>
  
  <p>I checked the ModelState error and the exception I'm getting is </p>
  
  <pre><code>"The parameter conversion from type 'System.String' to type Models.SystemFailureAction' failed because no type converter can convert between these types."
  </code></pre>
  
  <p>I also removed the logic that adds the Failure types and I'm still receiving the same issue. So it appears the problem is coming from mapping the Viewmodel.action.Description to the action.</p>