I'm trying to configure an OData endpoint for my Web API service and I can not resolve the MapODataRoute
method. As per this tutorial the following is stated about the requirments:
ASP.NET and Web Tools 2012.2 Update or the Microsoft ASP.NET Web API OData NuGet package.
I have the current ASP.NET and Web Tools 2012.2 Update installed (had uninstalled the RC version and installed the newest one), so my project should suffice.
However I can't get past the following line of code:
config.Routes.MapODataRoute("ODataRoute", "odata", model);
...due to the following exception:
'System.Web.Http.HttpRouteCollection' does not contain a definition for 'MapODataRoute' and no extension method 'MapODataRoute' accepting a first argument of type 'System.Web.Http.HttpRouteCollection' could be found (are you missing a using directive or an assembly reference?)
I believe if I install the NuGet package this message would resolve (and it's no big deal to install it), but I thought all the OData support was rolled up into the 'ASP.NET and Web Tools 2012.2 Update' thus not requiring the NuGet package? Does anyone know why MapODataRoute
is not resolving or which reference I need?
From the same tutorial:
If you installed ASP.NET and Web Tools 2012.2 Update, then the Web API project template automatically includes the OData packages.
So, check nuget packages of your project, whether odata packages are present.
May be, you installed new version of ASP.NET and Web Tools and then open your old project. I suspect that you don't need manually add odata packages only if you create project after you installed ASP.NET and Web Tools 2012.2 Update.