Problems Getting Started w/ EF5 and WCF Data Services

Posts   
 
    
Emmanuel
User
Posts: 167
Joined: 13-Jan-2006
# Posted on: 07-May-2015 02:14:58   

I'm a longtime LLBLGen framework user and am trying the designer as an EF code generator for the first time. I'll be needing to provide a WCF Data Services OData service of the entities.

I generated EF5 entities (model and persistence) projects and did a test console app that successfully does an eager loading of a collections of records directly with the SQL provider. No problem. However, when I put together a WCF Data Service web app and access my .svc URL, I get an exception "On data context type 'MyDataContext', there is a top IQueryable property 'MyEntities' whose element type is not an entity type".

Also, when I try to open the generated EDMX model in VS 2013 (12.0.31101.00 Update 4), I get the message "The Entity Data Model Designer is unable to display the file you requested".

I'm using designer version 4.2 build Feb 16 2015. EF5. General template group. SD.EntityFramework.v5 (DbContext API) Preset. Targetting .NET 4.5. Template bindings and tasks queue are the default ones. Database is SQL Server Express 10.5. I'm referencing version 5.6.3.0 of Microsoft.Data.* assemblies and version 5 of EntityFramework.

My svc.cs InitializeService() looks like this:

public class ApplicationData : DataService<ApplicationDataDataContext>
{
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    {
        config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
        config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;

        config.UseVerboseErrors = true;
    }

...

Here's the exception:

System.InvalidOperationException: On data context type 'ApplicationDataDataContext', there is a top IQueryable property 'AccountingSoftwares' whose element type is not an entity type. Make sure that the IQueryable property is of entity type or specify the IgnoreProperties attribute on the data context type to ignore this property. at System.Data.Services.Providers.ReflectionServiceProvider.PopulateMetadata(ProviderMetadataCacheItem metadataCacheItem) at System.Data.Services.Providers.BaseServiceProvider.LoadMetadata(Boolean skipServiceOperations) at System.Data.Services.DataService1.CreateInternalProvider(Object dataSourceInstance) at System.Data.Services.DataService1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider& metadataProviderInstance, IDataServiceQueryProvider& queryProviderInstance, Object& dataSourceInstance, Boolean& isInternallyCreatedProvider) at System.Data.Services.DataService1.CreateProvider() at System.Data.Services.DataService1.HandleRequest() at System.Data.Services.DataService`1.ProcessRequestForMessage(Stream messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-May-2015 07:25:50   

Does this help? :[http://stackoverflow.com/questions/26864806/exception-message-is-on-data-context-type-there-is-a-top-iqueryable-property-who](http://stackoverflow.com/questions/26864806/exception-message-is-on-data-context-type-there-is-a-top-iqueryable-property-who)

(Edit) About the EDMX error on VS.Net, please check this: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=18125&StartAtMessage=0&#101395

David Elizondo | LLBLGen Support Team
Emmanuel
User
Posts: 167
Joined: 13-Jan-2006
# Posted on: 07-May-2015 13:36:18   

daelmo wrote:

Does this help? :[http://stackoverflow.com/questions/26864806/exception-message-is-on-data-context-type-there-is-a-top-iqueryable-property-who](http://stackoverflow.com/questions/26864806/exception-message-is-on-data-context-type-there-is-a-top-iqueryable-property-who)

Nope. I'm not even using a client yet - just browsing to the service.

daelmo wrote:

About the EDMX error on VS.Net, please check this: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=18125&StartAtMessage=0&#101395

Oh. I thought maybe I would end up with an EDMX that a VS-only user could use.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 07-May-2015 19:24:19   

Nope. I'm not even using a client yet - just browsing to the service.

Could you please try with a client, and make sure library versions and generated code matches all around the solution.

Emmanuel
User
Posts: 167
Joined: 13-Jan-2006
# Posted on: 10-May-2015 14:32:35   

Walaa wrote:

Could you please try with a client, and make sure library versions and generated code matches all around the solution.

I've solved the problem. I was testing my service installed on a separate machine which didn't have the Microsoft.Data.* assemblies installed in GAC and when NuGet installed them on my dev machine, it set Copy Local to false. But, I gather, because System.Data was referenced by the service project by default, the service fell back to that which didn't work.

So, actually, you were on the right track with your suggestions. Thanks.