config.MapODataServiceRoute error config.MapODataServiceRoute error asp.net asp.net

config.MapODataServiceRoute error


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.


MapODataServiceRoute is available in Routes Collection, hence below code will do

config.Routes.MapODataServiceRoute("odata", null, GetEdmModel(), new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));


FOR OData V3

  1. Install Microsoft.AspNet.WebApi.OData
  2. Add using System.Web.Http.OData.Builder; and using System.Web.Http.OData.Extensions;
  3. use like config.Routes.MapODataServiceRoute(...)

FOR OData V4

  1. Install Microsoft.AspNet.OData
  2. Add using System.Web.OData.Builder; and using System.Web.OData.Extensions;
  3. use like config.MapODataServiceRoute(...)

Dont get stuck on WebApi word, they are both for web api.