title: Web API + MVC 4 regarding model binding of complex types
body: <p>I have the following classes:</p>
  
  <pre><code>public class State
  {
      public long Id                    { get; set; }
      public string Name                { get; set; }
      public string Abbreviation        { get; set; }
  
      // Navigation Properties
      public virtual Country Country    { get; set; }
  }
  
  public class School
  {
      public long Id                    { get; set; }
      public string Name                { get; set; }
      public string Abbreviation        { get; set; }
  
      // Navigation Properties
      public virtual State State        { get; set; }
  }
  </code></pre>
  
  <p>and the following data in my SQL Server</p>
  
  <pre><code>| School|             |               |
  |  Id   | Name        |    State      |
  |  1    | UCLA        |      1        |
  +-------+-------------+---------------+
  | State |             |               |
  |  Id   | Name        | Abbreviation  |
  |  1    | California  |      CA       |
  </code></pre>
  
  <p>I'm attempting to create a Rest controller that creates an instance of school using the HTTP POST verb using Web API.</p>
  
  <pre><code>public HttpResponseMessage&lt;School&gt; Post( School school )
  {
      SchoolService.CreateSchool( school );
      var response = new HttpResponseMessage&lt;School&gt;( school, HttpStatusCode.Created );
      string uri = Url.Route( null, new { id = school.Id } );
  
      response.Headers.Location = new Uri( Request.RequestUri, uri );
      return response;
  }
  </code></pre>
  
  <p>Web API properly binds my School class's Name and Abbreviation properties from my web form and calls the POST method in the controller, but it doesn't know what to do with the State class. I'm not quite sure how to set that up. I'd like to have a dropdown that is bound to the State class and when I submit the creation of the School, the correct state from my existing data will get assigned to the new school instance.</p>