title: Breeze webapi controller 'cannot support querying' over DbSet error
body: <p>I have setup very similar to breeze sample application which comes in <a href="https://nuget.org/packages/Breeze.MVC4WebApiClientSample/0.82.1" rel="nofollow noreferrer">sample nuget</a>. This is the code of my api controller:</p>
  
  <pre><code>[JsonFormatter, ODataActionFilter]
  public class WorkOrdersController : ApiController
  {
      readonly EFContextProvider&lt;WorkOrdersContext&gt; _contextProvider =
          new EFContextProvider&lt;WorkOrdersContext&gt;();
  
      public WorkOrdersController()
      {
          // I was thinking this may be the cause of the issue
          this._contextProvider.Context.Configuration.ProxyCreationEnabled = false;
      }
  
      [HttpGet]
      public string Metadata()
      {
          return _contextProvider.Metadata();
      }
  
      [HttpPost]
      public SaveResult SaveChanges(JObject saveBundle)
      {
          return _contextProvider.SaveChanges(saveBundle);
      }
  
      [HttpGet]
      public IQueryable&lt;WorkOrder&gt; WorkOrders()
      {
          return _contextProvider.Context.WorkOrders;
      }
  
  }
  </code></pre>
  
  <p>The problem I'm having is when I try to perform query over <code>WorkOrders</code> action, I get 500 - Internal server error, and this is the payload of response:</p>
  
  <pre><code>{"$id":"1","$type":"System.Web.Http.HttpError, System.Web.Http","Message":"An error has occurred.","ExceptionMessage":"The action 'WorkOrders' on controller 'WorkOrders' with return type 'System.Collections.Generic.List`1[[WorkOrders.Domain.Models.WorkOrder, WorkOrders.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' cannot support querying. Ensure the type of the returned content is IEnumerable, IQueryable, or a generic form of either interface.","ExceptionType":"System.InvalidOperationException","StackTrace":"   at System.Web.Http.QueryableAttribute.ValidateReturnType(Type responseContentType, HttpActionDescriptor actionDescriptor)\r\n   at System.Web.Http.QueryableAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)\r\n   at System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEnd(ITraceWriter traceWriter, HttpRequestMessage request, String category, TraceLevel level, String operatorName, String operationName, Action`1 beginTrace, Action execute, Action`1 endTrace, Action`1 errorTrace)\r\n   at System.Web.Http.Tracing.Tracers.ActionFilterAttributeTracer.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.&lt;&gt;c__DisplayClass2.&lt;System.Web.Http.Filters.IActionFilter.ExecuteActionFilterAsync&gt;b__0(HttpResponseMessage response)\r\n   at System.Threading.Tasks.TaskHelpersExtensions.&lt;&gt;c__DisplayClass41`2.&lt;Then&gt;b__40(Task`1 t)\r\n   at System.Threading.Tasks.TaskHelpersExtensions.ThenImpl[TTask,TOuterResult](TTask task, Func`2 continuation, CancellationToken cancellationToken, Boolean runSynchronously)"}
  </code></pre>
  
  <p>WorkOrders is Dbset on context:</p>
  
  <pre><code>public DbSet&lt;WorkOrder&gt; WorkOrders { get; set; }
  </code></pre>
  
  <p>I have also tried explicitly casting it to IQueryable, with no change:</p>
  
  <pre><code>[HttpGet]
  public IQueryable&lt;WorkOrder&gt; WorkOrders()
  {
      return (IQueryable&lt;WorkOrder&gt;)_contextProvider.Context.WorkOrders;
  }
  </code></pre>
  
  <p>The only thing that works for me is:</p>
  
  <p>[HttpGet]
      public IEnumerable WorkOrders()
      {
          return _contextProvider.Context.WorkOrders.AsEnumerable();
      }</p>
  
  <p>This, however causes another problem for me on the client side, described in <a href="https://stackoverflow.com/q/14148828/408643">this</a> question.</p>