I am currently following this guide -> Link to asp.net website
As the guide says I added all the necessary packages via the nuget console and added the necessary usings
I just had this problem. Very frustrating.
I resolved it by adding this in the references at the top of the code page
using System.Web.OData.Extensions;
Right clicking the method did not bring up the resolve menu item either.
Reinstalling everything did no resolve anything for me.
I fixed this by opening the package manager console, setting the default project to the project that gave the error message, and then:
Install-Package Microsoft.AspNet.WebApi.OData
MapODataServiceRoute is available in Routes Collection, hence below code will do
config.Routes.MapODataServiceRoute(
"odata",
null,
GetEdmModel(),
new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));
FOR OData V3
using System.Web.Http.OData.Builder;
and using System.Web.Http.OData.Extensions;
config.Routes.MapODataServiceRoute(...)
FOR OData V4
using System.Web.OData.Builder;
and using System.Web.OData.Extensions;
config.MapODataServiceRoute(...)
Dont get stuck on WebApi word, they are both for web api.
MapODataServiceRoute
is extension method. So to use it a reference to its namespace is required. For me it was fixed by referencing:
using System.Web.Http.OData.Extensions;
If you have upgraded to Microsoft.AspNet.OData 7.0.0
then the namespace you are looking for is:
using Microsoft.AspNet.OData.Extensions;