After upgrading the ASP NET Web API project framework to the Core 2.2 version, the OData route configuration fails. It throws "Cannot use 'Microsoft.AspNet.OData.Routing.ODataRoute' with Endpoint Routing." Exception.
The link https://github.com/Microsoft/aspnet-api-versioning/issues/361 shows how to avoid the exception but disabling the new Core 2.2 routing model. Can you tell me how to solve the problem without deactivating this functionality?
public IServiceProvider ConfigureServices(IServiceCollection services)
{
...
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2).AddControllersAsServices();
...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
...
app.UseMvc(b =>
{
b.Select().Expand().Filter().OrderBy().MaxTop(100).Count();
b.MapODataServiceRoute("odata", "odata", ODataConfig.GetEdmModel());
});
}