Showing posts with label WCF Data Services. Show all posts
Showing posts with label WCF Data Services. Show all posts

Thursday, March 21, 2013

Updating 'Microsoft.Data.OData 5.2.0' to 'Microsoft.Data.OData 5.3.0' failed


Updating 'Microsoft.Data.OData 5.2.0' to 'Microsoft.Data.OData 5.3.0' failed. Unable to find a version of 'Microsoft.AspNet.WebApi.OData' that is compatible with 'Microsoft.Data.OData 5.3.0'.

WCF Data Services 5.3.0 RTW has been released few days back. Once you install it using the tools installer, it will update the "Add Service Reference" tooling integration in Visual Studio, after which it'll create the code based on the WCF Data Services 5.3.0.  In such case, for now if you try to add service reference to a WCF Data Service in an ASP.NET MVC 4 project you might end up getting the error specified at the top of this page.

As mentioned in the error, it seems that the respective "Microsoft.AspNet.WebApi.OData" dll is not available in the last ASP.NET MVC 4 update. Hope this will be made available in the next related update.

Solution: Uninstall the respective program installed using the WCF Data Services 5.3.0 RTW tools installer. If you try the service reference now it'll get you with Microsoft.Data.OData 5.2.0 in the client. This way we can go with WCF Data Service created with 5.3.0 version and the respective client libraries (proxy....) with 5.2.0 (in ASP.NET MVC 4 client projects). Just tried locally, but didn't verified entire features.
As an alternate try with Nuget packages.

Friday, August 10, 2012

WCF Data Services - OData - Initial errors developers encounters

When authoring WCF Data Services - OData, lot of developers tries to view it in the browser during several stages of developement. Mostly they will come across the following error at initial stages.

The server encountered an error processing the request. See  server logs for more details.

When we think of creating WCF Data services, its better to have the following minimal understanding.

WCF Data services / OData service : A .Net framework component which is used to create services that uses Open Data Protocol (OData). This service exposes data through the endpoint which allows to access the data.

OData client libraries : Though not strictly required, several client libraries available for easy and effective access of OData format. Based on the client applications we create, we can make use of the respective client libraries. For example we have separate libraries for .Net, java, javascript, Silverlight, etc.

OData data model : Makes use of the exiting .Net member called Entity Data Model(EDM).  The data to be represented need to be modeled using EDM.

OData Protocol : This protocol is REST based. Defines  how the data model will be represented over the wire - either in XML based format defined by ATOM or in JSON format.

Now, let us look at the cause for the issue.

In the InitializeService method of the svc.cs file, do ensure whether the SetEntitySetAccessRule is specified for the respective entity and most important, the name of the entity set should be pluralized (if opted while creating the entity data model).

Snippet 1


// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
    // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
    // Examples:
    config.SetEntitySetAccessRule("Employees", EntitySetRights.AllRead);
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}

References

Creative Commons License
This work by Tito is licensed under a Creative Commons Attribution 3.0 Unported License.