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.DataService
1.CreateMetadataAndQueryProviders(IDataServiceMetadataProvider& metadataProviderInstance, IDataServiceQueryProvider& queryProviderInstance, Object& dataSourceInstance, Boolean& isInternallyCreatedProvider)
at System.Data.Services.DataService1.CreateProvider()
at System.Data.Services.DataService
1.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)