title: Request error with WCF Data Services
body: <p>Its my first time setting up an OData Service and I'm of course having some problems...</p>
  
  <p>The problem is that I can't get the service running, I keep getting an "Request Error".
  <img src="https://i.stack.imgur.com/KH2XP.png" alt="Request Error"></p>
  
  <p>I have <a href="http://www.bondigeek.com/blog/2010/12/11/debugging-wcf-data-services/">researched</a> on what the problem can be and I found that a common issue is that the access rules are incorrectly typed. So I have tried fixing this both with Singular names, Plural names and I have also tried with <code>typeof(Post).getType().Name</code></p>
  
  <p>Well here is my code. I hope you can help me, I've been stuck for hours.</p>
  
  <pre><code>public class ODataService : DataService&lt;Entity&gt;
  {
      // This method is called only once to initialize service-wide policies.
      public static void InitializeService( DataServiceConfiguration config )
      {
          //config.SetEntitySetAccessRule( "Users", EntitySetRights.All );
          //config.SetEntitySetAccessRule( "Posts", EntitySetRights.All );
          //config.SetEntitySetAccessRule( "Albums", EntitySetRights.All );
  
  
          config.SetEntitySetAccessRule( "*", EntitySetRights.AllRead );
          config.SetServiceOperationAccessRule( "*", ServiceOperationRights.AllRead );
          //config.SetServiceOperationAccessRule( "GetPosts", ServiceOperationRights.AllRead );
  
          config.UseVerboseErrors = true;
          config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
      }
  
      [WebGet]
      public IQueryable&lt;Post&gt; GetPosts()
      {
          return CurrentDataSource.Posts.AsQueryable();
      }
  }
  </code></pre>
  
  <p>The structure of my EntityFramework class (db first)
  <img src="https://i.stack.imgur.com/heOmx.png" alt="The structure of my EntityFramework class (db first)" title="The structure of my EntityFramework class (db first)"></p>
  
  <p>Methods and Members for Entity class. Here the entities are spelled in plural.
  <img src="https://i.stack.imgur.com/VXyGR.png" alt="Methods and Members for Entity class" title="Methods and Members for Entity class"></p>
  
  <p>This is my Web.config:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!--
    For more information on how to configure your ASP.NET application, please visit
    http://go.microsoft.com/fwlink/?LinkId=169433
    --&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="Entity" connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=XXX;Initial Catalog=XXX;persist security info=True;user id=XXX;password=XXX;MultipleActiveResultSets=True;App=EntityFramework&amp;quot;" providerName="System.Data.EntityClient" /&gt;
    &lt;/connectionStrings&gt;
    &lt;appSettings&gt;
      &lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&gt;
      &lt;add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5" /&gt;
      &lt;httpRuntime requestValidationMode="4.5" targetFramework="4.5" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
      &lt;pages controlRenderingCompatibilityVersion="4.5" /&gt;
      &lt;machineKey compatibilityMode="Framework45" /&gt;
    &lt;/system.web&gt;
  &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="LinkIT.Core.OData.ODataService"  behaviorConfiguration ="DebugEnabled"&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors &gt;
          &lt;behavior name="DebugEnabled"&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="True"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>A detailed error message:</p>
  
  <blockquote>
    <p>The server encountered an error processing the request. The exception
    message is 'Value cannot be null. Parameter name:
    propertyResourceType'. See server logs for more details. The exception
    stack trace is:</p>
    
    <p>at System.Data.Services.WebUtil.CheckArgumentNull[T](T value, String
    parameterName) at
    System.Data.Services.Providers.ResourceProperty..ctor(String name,
    ResourcePropertyKind kind, ResourceType propertyResourceType) at
    System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMemberMetadata(ResourceType
    resourceType, IProviderMetadata workspace, IDictionary<code>2 knownTypes,
    PrimitiveResourceTypeMap primitiveResourceTypeMap) at
    System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMetadata(IDictionary</code>2
    knownTypes, IDictionary<code>2 childTypes, IDictionary</code>2 entitySets) at
    System.Data.Services.Providers.BaseServiceProvider.PopulateMetadata()
    at System.Data.Services.Providers.BaseServiceProvider.LoadMetadata()
    at
    System.Data.Services.DataService<code>1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider&amp;
    metadataProviderInstance, IDataServiceQueryProvider&amp;
    queryProviderInstance, BaseServiceProvider&amp; builtInProvider, Object&amp;
    dataSourceInstance) at
    System.Data.Services.DataService</code>1.CreateProvider() at
    System.Data.Services.DataService<code>1.HandleRequest() at
    System.Data.Services.DataService</code>1.ProcessRequestForMessage(Stream
    messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] ,
    Object[] ) at
    System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object
    instance, Object[] inputs, Object[]&amp; outputs) at
    System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;
    rpc) at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;
    rpc) at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp;
    rpc) at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp;
    rpc) at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp;
    rpc) at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp;
    rpc) at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp;
    rpc) at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp;
    rpc) at
    System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp;
    rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
    isOperationContextSet)</p>
  </blockquote>