Home > OS >  After migrating from .net core 3.1 to .net 6.0 MapVersionedODataRoutes method under Microsoft.AspNet
After migrating from .net core 3.1 to .net 6.0 MapVersionedODataRoutes method under Microsoft.AspNet

Time:12-09

Currently I am using .netcore 3.1 project. Started migrating it to .net6.0

Below code is currently implemented in .netcore3.1

app.UseMvc(b =>
            {
                b.MapVersionedODataRoutes("odata-versioned", "odata", edmModels);
            });

After migrating the framework to .net6.0 and I am getting error that MapVersionedODataRoutes is not available. Are there a breaking changes? What is the new way of implementing the same.

Got stuck as the MapVersionedODataRoutes was not available

CodePudding user response:

Do you want to implement API versioning? In OData 8.0.11, you can implement it by AddRouteComponents:

builder.Services.AddControllers()
    .AddOData(opt => opt.AddRouteComponents("v{version}", edmModel));

For more details, you can refer to this link.

In addition, Microsoft.AspNetCore.OData.Versioning contains a MapVersionedODataRoute property, which may help you.

  • Related