Search code examples
.netwcf-data-services

Is this a bug? : I get " The type ... is not a complex type or an entity type" in my WCF data service using the Reflection provider


When invoking a query on the data service I get this error message inside the XML feed:

  <m:error>
    <m:code></m:code>
    <m:message xml:lang="nl-NL">Internal Server Error. The type 'MyType' is not a complex type or an entity type.</m:message>
  </m:error>

When I use the example described here in the article "How to: Create a Data Service Using the Reflection Provider (WCF Data Services)" http://msdn.microsoft.com/en-us/library/dd728281(v=VS.100).aspx it works as expected.

I have created the service in a .NET 4.0 web project. My data context class returns a query object that is derived from the LINQExtender (http://linqextender.codeplex.com/). When I execute the query object in a unit test, it works as expected.

My entity type is defined as:

[DataServiceKey("Id")]
public class Accommodation
{
    [UniqueIdentifier]
    [OriginalFieldName("EntityId")]
    public string Id { get; set; }

    [OriginalFieldName("AccoName")]
    public string Name { get; set; }
}

(the UniqueIdentifier and OriginalFieldName attributes are used by LINQExtender)

Does anybody know if this is a bug in WCF data services or am I doing something wrong?


Solution

  • There is a known bug in .NET 4 which is similar to the issue you described (as you obfuscated MyType can't be 100% sure).

    From Ptatik Patel (Microsoft):

    This is a known issue with the WCF Data Services. As Joe said, to make this work, you need to turn off the proxy generation - pretty bad. Sorry, i don't have a better answer at this point, but its too late to fix this in VS 2010 RTM.