Open hfaran opened 4 years ago
@hfaran Thanks for reporting this. found the issue is currently caused by the following lines https://github.com/OData/WebApi/blob/master/src/Microsoft.AspNetCore.OData/Extensions/ODataServiceCollectionExtensions.cs#L78-L87
@marabooy Thanks for the ack.
If
.AddOData()
is called twice, an exception is thrown. Similar to most other ASP.NET CoreAdd*
methods,.AddOData()
should be idempotent, but it is currently not.Assemblies affected
Microsoft.AspNetCore.OData.dll
Reproduce steps
services.AddOData()
twice in yourStartup.ConfigureServices
method.Expected result
AddOData()
should return the sameIODataBuilder
if called multiple times. The operation should be idempotent.Actual result
The following exception is thrown on the second invocation of
AddOData()
:Additional detail
An obvious suggestion to this may to be to "not call
.AddOData()
more than once". Sure, that would fix it, but we need to call it twice due to the way our framework is set up (the second call is required to get theIODataBuilder
so that we can use aspnet-api-versioning).