AspNetCoreOData
AspNetCoreOData copied to clipboard
Routing with OData Using Areas
We have a number of existing controllers with the same names as our OData controllers and we would like to keep it that way since we use /api/controller for the current routing and want to use odata/controller for new odata enabled controllers. I have reviewed some of the odata and routing documents and in particular https://devblogs.microsoft.com/odata/routing-in-asp-net-core-8-0-preview/ since it applies to version 8 which I am using. I was thinking that the easiest way would be to use Areas so that my controllers could be of the same name but I could not come up with a configuration via maproute or attributes that worked and always ended up with an error "Attribute routes with the same name 'odata/controller' must have the same template" it would then list "api/controller/odata/controller" and "odata/controller" as the two with problem. If I rename the controller, it works but I would like to leave them the same for backward compatibility. Are Areas supported by OData routing? Is there another way to achieve what I am trying to do, same controller names, different routes?
Thank you in advance.
Hi, I was having the same issue - [ODataModelAttribute] is the way to go in this case. Please take a look at #37 , in particular https://github.com/OData/AspNetCoreOData/issues/37#issuecomment-735705937
@wjvii Was your issue resolved?