Search code examples
.netentity-frameworkwcf-data-servicesodata

Can I use a complex datatype with an EF-provided WCF Data Services without telling EF about it?


I am using an Entity Framework-provided WCF DataService to expose an OData endpoint. I want to create a Service Operation that returns a new type. But I get:

The exception message is 'Unable to load metadata for return type 'System.Linq.IQueryable1[MyNamespace+MyNewType]' of method 'System.Linq.IQueryable1[MyNamespace+MyNewType] FlightHours()'.'. See server logs for more details.

How can I let the DataService know I want it to grok MyNewType? Do I have to hackily make a fake entity on the EF DataContext, or can I simply "add" it in somehow? This post came up with that hack but I was hoping things had changed or that they missed something.

Update with relevant links:


Solution

  • There's currently no other way than to teach the EF that such a type exists. When you use the EF provider for WCF DS, the entire metadata comes solely from EF, WCF DS doesn't modify it in any (meaningful) way.