title: How do you create an action in MVC with oData
body: <p>I have tried to follow the example code at </p>
  
  <p><a href="https://aspnet.codeplex.com/sourcecontrol/latest#Samples/WebApi/ODataActionsSample/ODataActionsSample/NonBindableActionRoutingConvention.cs" rel="nofollow">https://aspnet.codeplex.com/sourcecontrol/latest#Samples/WebApi/ODataActionsSample/ODataActionsSample/NonBindableActionRoutingConvention.cs</a> </p>
  
  <p>as well as I can.</p>
  
  <p>WebApiConfig:</p>
  
  <pre><code>        config.Routes.MapODataRoute(
                  "AppAccountOData",
                  "odata",
                  GetModel()
              );
  </code></pre>
  
  <p>... </p>
  
  <p>API routes<br>
  ...</p>
  
  <pre><code>        public static IEdmModel GetModel()
      {
          var builder = new ODataConventionModelBuilder();
          builder.EntitySet&lt;User&gt;("Users");
          builder.EntitySet&lt;EventLog&gt;("EventLogs");
          builder.EntitySet&lt;Server&gt;("Servers");
          builder.EntitySet&lt;Database&gt;("Databass");
          builder.EntitySet&lt;Command&gt;("Commands");
          builder.EntitySet&lt;Connection&gt;("Conenctions");
          builder.EntitySet&lt;Query&gt;("Queries");
          builder.EntitySet&lt;DirectoryGroup&gt;("DirectoryGroups");
          builder.EntitySet&lt;ServiceAccount&gt;("ServiceAccounts");
          builder.EntitySet&lt;EmailLog&gt;("EmailLogs");
          builder.EntitySet&lt;EmailTemplate&gt;("EmailTemplates");
          builder.EntitySet&lt;EventLog&gt;("EventLogs");
          builder.EntitySet&lt;EventLogLevel&gt;("EventLogLevels");
          builder.EntitySet&lt;EventLogSource&gt;("EventLogSources");
          builder.EntitySet&lt;ApplicationServer&gt;("ApplicationServers");
          builder.EntitySet&lt;ApplicationOnboardings_Old&gt;("ApplicationOnboardings_Olds");
          builder.EntitySet&lt;ApplicationContact&gt;("ApplicationContacts");
          builder.EntitySet&lt;ApplicationCategory&gt;("ApplicationCategories");
          builder.EntitySet&lt;ApplicationOnboardingStatusType&gt;("ApplicationOnboardingStatusTypes");
          builder.EntitySet&lt;ApplicationOnboarding&gt;("ApplicationOnboardings");
          builder.EntitySet&lt;Application&gt;("Applications");
          builder.EntitySet&lt;AppAccount&gt;("AppAccounts");
          builder.EntitySet&lt;vAppAccountUser&gt;("vAppAccountUsers");
          builder.EntitySet&lt;vUnmatchedAppAccount&gt;("vUnmatchedAppAccounts");
          builder.EntitySet&lt;vTerminatedUser&gt;("vTerminatedUsers");
          builder.EntitySet&lt;SvcAccount&gt;("SvcAccounts");
          builder.EntitySet&lt;AppAccountClass&gt;("AppAccountClasses");
  
          var serviceAccounts = builder.Entity&lt;AppAccount&gt;().Collection.Action("Service");
          serviceAccounts.ReturnsCollectionFromEntitySet&lt;AppAccount&gt;("AppAccounts");
  
          return builder.GetEdmModel();
  
      }
  </code></pre>
  
  <p>The function in the controller is simple:</p>
  
  <pre><code>    [HttpGet]
      public ICollection&lt;AppAccount&gt; Service(ODataQueryOptions opts)
      {
          var results = opts.ApplyTo(db.AppAccounts.Where(aa =&gt; aa.AppAccountClass.Name == "Service")) as IQueryable&lt;AppAccount&gt;;
          if (results != null) return results.ToList();
          throw new HttpResponseException(HttpStatusCode.BadRequest);
      }
  </code></pre>
  
  <p>When I call this, I receive an error: </p>
  
  <p>Not implemented. This service doesn't support OData requests in the form '~/entityset/action'.</p>