title: Posting to an Odata service only receives pimitive data
body: <p>I am building  an Odata web service and utilizing the Entity Framework where my intent is to Post a given Receipt which has some primitive properties. The Receipt also contains a collection of ReceiptLines which is also composed of primitive properties.</p>
  
  <p>Here is my issue: I can Post to the service just fine. When I step through the Post process on the server side with the debugger the Receipt I am posting no longer contains any ReceiptLines. I verify that I do submit the Receipt with ReceiptLines. Am I missing something in my design which is omitting the ReceiptLines when posted from the client? </p>
  
  <p>I have included my code from my ReceiptController, WebApiConfig, and metadata below. Any advice is most welcome.</p>
  
  <p>ReceiptController:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data.Entity;
  using System.Data.Entity.Infrastructure;
  using System.Linq;
  using System.Net;
  using System.Threading.Tasks;
  using System.Web.Http;
  using System.Web.OData;
  using System.Web.OData.Routing;
  using AccountsReceivableWebService.Models;
  
  namespace AccountsReceivableWebService
  {
    public class ReceiptsController : ODataController
    {
      static ReceiptsContext db = new ReceiptsContext() { Receipts = new List&lt;Receipt&gt;() };
  
      #region Receipt portion
  
      private bool ReceiptExitsts(string key)
      {
        return db.Receipts.Count(r =&gt; r.ReceiptId == key) &gt; 0;
      }
  
      [EnableQuery]
      public IQueryable&lt;Receipt&gt; Get()
      {
        return db.Receipts.AsQueryable();
      }
  
      [EnableQuery]
      public Receipt Get([FromODataUri] int key)
      {
        return db.Receipts.First(r=&gt;r.ReceiptId==key.ToString());
      }
  
      /// &lt;summary&gt;
      /// This is the Post portion of CRUD operations.
      /// &lt;/summary&gt;
      /// &lt;param name="receipt"&gt;&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public IHttpActionResult Post(Receipt receipt)
      {
        if (!ModelState.IsValid) return BadRequest(ModelState);
        if (!receipt.Insert())
        {
          //db.Receipts.Add(receipt);
          BadRequest(receipt.Proof());
        }
        else
        {
          if (db.Receipts.Count(r =&gt; r.ReceiptId == receipt.ReceiptId) == 0)
            db.Receipts.Add(receipt);
        }
        return Created(receipt);
      }
  
      /// &lt;summary&gt;
      /// Checks that this receipt is a valid receipt
      /// &lt;/summary&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      [HttpPost]
      public IHttpActionResult Proof([FromBody] Receipt parameters)
      {
        string returnStr = "";
        if (!ModelState.IsValid) return BadRequest(ModelState);
        foreach (Receipt r in db.Receipts)
        {
          string temp = r.Proof();
          if (temp != "")
          {
            returnStr = string.Format("{0}: {1};", r.ReceiptId, temp);
          }
        }
        return Ok(new List&lt;string&gt;() {"hello"});
      }
      #endregion
  
      #region ReceiptLine portion
  
      [ODataRoute("Receipts({receiptId})/ReceiptLines/AccountsReceivableWebService.GetCount()")]
      public IHttpActionResult GetCount(string receiptId)
      {
        return Ok(db.Receipts.Single(r =&gt; r.ReceiptId == receiptId).ReceiptLines.Count);
      }
      #endregion
    }
  }
  </code></pre>
  
  <p>WebApiConfig:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web.Http;
  using AccountsReceivableWebService.Models;
  using System.Web.OData.Builder;
  using System.Web.OData.Extensions;
  
  namespace AccountsReceivableWebService
  {
    public static class WebApiConfig
    {
      public static void Register(HttpConfiguration config)
      {
        // Web API configuration and services
  
        // Web API routes
        ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
  
        builder.Namespace = "AccountsReceivableWebService";
        builder.EntitySet&lt;Receipt&gt;("Receipts");
        builder.EntityType&lt;ReceiptLine&gt;().Collection.Function("GetCount").Returns&lt;int&gt;();
  
        config.MapODataServiceRoute(
              routeName: "ODataRoute",
              routePrefix: null,
              model: builder.GetEdmModel());
  
      }
    }
  }
  </code></pre>
  
  <p>metadata:</p>
  
  <pre><code>&lt;edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0"&gt;
    &lt;edmx:DataServices&gt;
      &lt;Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="AccountsReceivableWebService.Models"&gt;
        &lt;EntityType Name="Receipt"&gt;
          &lt;Key&gt;
            &lt;PropertyRef Name="ReceiptId"/&gt;
          &lt;/Key&gt;
          &lt;Property Name="ReceiptId" Type="Edm.String" Nullable="false"/&gt;
          &lt;Property Name="comments" Type="Edm.String"/&gt;
          &lt;Property Name="remitter" Type="Edm.String"/&gt;
          &lt;Property Name="ReceiptLineId" Type="Edm.String"/&gt;
          &lt;NavigationProperty Name="ReceiptLines" Type="Collection(AccountsReceivableWebService.Models.ReceiptLine)" ContainsTarget="true"/&gt;
        &lt;/EntityType&gt;
        &lt;EntityType Name="ReceiptLine"&gt;
          &lt;Key&gt;
            &lt;PropertyRef Name="ReceiptLineId"/&gt;
          &lt;/Key&gt;
          &lt;Property Name="ReceiptLineId" Type="Edm.String" Nullable="false"/&gt;
          &lt;Property Name="Comments" Type="Edm.String"/&gt;
          &lt;Property Name="FiscalYear" Type="Edm.String"/&gt;
          &lt;Property Name="CostCenter" Type="Edm.String"/&gt;
          &lt;Property Name="object" Type="Edm.String"/&gt;
          &lt;Property Name="Amount" Type="Edm.String"/&gt;
          &lt;Property Name="Function" Type="Edm.String"/&gt;
        &lt;/EntityType&gt;
      &lt;/Schema&gt;
      &lt;Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="AccountsReceivableWebService"&gt;
        &lt;Function Name="GetCount" IsBound="true"&gt;
        &lt;Parameter Name="bindingParameter" Type="Collection(AccountsReceivableWebService.Models.ReceiptLine)"/&gt;
        &lt;ReturnType Type="Edm.Int32" Nullable="false"/&gt;
        &lt;/Function&gt;
        &lt;EntityContainer Name="Container"&gt;
        &lt;EntitySet Name="Receipts" EntityType="AccountsReceivableWebService.Models.Receipt"/&gt;
        &lt;/EntityContainer&gt;
      &lt;/Schema&gt;
    &lt;/edmx:DataServices&gt;
  &lt;/edmx:Edmx&gt;
  </code></pre>