Versioning OData controllers
It is good practice to plan for future versions of your OData models that might have different schemas and behavior.
To maintain backward compatibility, you can use OData URL prefixes to specify a version number:
- In the
Northwind.OData.Serviceproject, inProgram.cs, in the services configuration section, after adding the two OData models forcatalogandorders, add a third OData model that has a version number and uses the sameGetEdmModelForCatalogmethod, as shown highlighted in the following code:.AddRouteComponents(routePrefix: "catalog", model: GetEdmModelForCatalog()) .AddRouteComponents(routePrefix: "ordersystem", model: GetEdmModelForOrderSystem()) .AddRouteComponents(routePrefix: "catalog/v{version}", model: GetEdmModelForCatalog()) - In
ProductsController.cs, modify theGetmethods to add astringparameter namedversionthat defaults to"1", and use it to change...