Another fun error with WCF Data Services

Monday, April 4, 2011
by asalvo

I’m back doing another spike with WCF data services. This time using the Entity Framework 4.1 RC and the WCF Data Services CTP 2 (which enables support for EF 4.1’s DbContext API). Once again I am faced with a no so helpful error message. Remembering back to my last visit with WCF Data Services I made the change to include the exception detail to get a better idea of what was going on and was rewarded with the following.

The server encountered an error processing the request. The exception message is 'An exception occurred while initializing the database. See the InnerException for details.'. See server logs for more details. The exception stack trace is: 

at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) at System.Data.Entity.Internal.LazyInternalContext.get_ObjectContext() at System.Data.Services.Caching.MetadataCache.TryLookup(Type serviceType, Object dataContextInstance) at System.Data.Services.DataService`1.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)

I scratched my head for a bit, and then I realized I was dumb. I had forgot to give the website permissions to the database. I was curious to see what execption I would get if I invoked the code with an invalid connection string in my unit test project and found a rather strange behavior. With the incorrect database specified in the connection string, I got no exception at all, just an empty result set returned! I should note that I do not have any DB Initializers configured since the database I’m working with already exists.

I have a feeling I will be posting more about my EF 4.1 and WCF Data Services project in the future.

Comments

comments powered by Disqus