views:

296

answers:

2

While trying to use the entity framework and ado.net data services, I'm hitting a real headscratcher.

Before the request even makes it to my code, i get a WCF exception (Exception at the bottom). It's not very helpful at all. All my entites have primary keys and all properties on all entities are public. Any ideas what can be causing this?

Exception Text: The server encountered an error processing the request. The exception message is 'The given key was not present in the dictionary.'. See server logs for more details. The exception stack trace is:

at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary2.get_Item(TKey key) at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMemberMetadata(ResourceType resourceType, MetadataWorkspace workspace, IDictionary2 entitySets, IDictionary2 knownTypes) at System.Data.Services.Providers.ObjectContextServiceProvider.PopulateMetadata(IDictionary2 knownTypes, IDictionary2 entitySets) at System.Data.Services.Providers.BaseServiceProvider.PopulateMetadata() at System.Data.Services.DataService1.CreateProvider(Type dataServiceType, Object dataSourceInstance, DataServiceConfiguration& configuration) at System.Data.Services.DataService1.EnsureProviderAndConfigForRequest() at System.Data.Services.DataService1.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.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

A: 

The problem is occuring in "DataServiceConfiguration". The error is "'The given key was not present in the dictionary".

In most cases when this has happened to me, it has been something missing in the configuration. The program reads the information from the configuration file into a dictionary, then tries to look up a key, and gets a key not found exception.

Shiraz Bhaiji
Where would that configuration be? As far as I can tell, all data service configuration is done in the cs file.
midas06
A: 

It is probably the connection string for the entity framework model. make sure you have it on the web application config file.

dmportella