Search code examples
odataaspnetboilerplate

Why does Abp.AspNetCore.OData require services.AddOData()?


In the aspnetboilerplate documentation is a tutorial on how to use the Abp.AspNetCore.OData module. I study this module as a reference for creating my own GraphQL module. However, I am somewhat confused on why after declaring a dependency on the OData module it is still required to explicitly configure the services with

services.AddOData();

inside the Startup class from the actual Asp.NET Core project?

Sure, it is required because the Abp.AspNetCore.OData module does not do it. But isn't a big part of the idea of ABP's module system to automatically register all dependencies when declaring a dependency on a specific module with the DependsOn attribute? This way the encapsulation in a ABP module seems somewhat useless.


Solution

  • services.AddOData() is called in Startup.cs; it would require hacking around to be called in an ABP module.

    Often, services.AddXxx() calls depend on the earlier adding of other services.

    Not all of those services are going to be ABP modules so it's not possible to make sure that they are called in the order that the service needs and the developer wants.