title: inject all services in startup.cs, .net core, overloaded
body: <p>This is more a general question.</p>
  <p>But I have a question about injecting services in the startup.cs:</p>
  <pre><code>public void ConfigureServices(IServiceCollection services)
          {            
  
              services.AddControllers(opt =&gt;
              {
                  var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
                  opt.Filters.Add(new AuthorizeFilter(policy));
              })
                  .AddFluentValidation(config =&gt;
              {
                  config.RegisterValidatorsFromAssemblyContaining&lt;Create&gt;();
              });
              services.AddApplicationServices(Configuration);
              services.AddIdentityServices(Configuration);           
          }
  </code></pre>
  <p>So anyway I split the services in other file:</p>
  <pre><code>public static class StartupExtensionClass
      {
          public static IServiceCollection AddApplicationServices(this IServiceCollection services,
              IConfiguration Configuration)
          {
  
              services.AddSwaggerGen(c =&gt;
            {
                c.SwaggerDoc(&quot;v1&quot;, new OpenApiInfo { Title = &quot;API&quot;, Version = &quot;v1&quot; });
            });
  
              services.AddDbContext&lt;DataContext&gt;(options =&gt;
                options.UseSqlServer(Configuration.GetConnectionString(&quot;DefaultConnection&quot;)));
  
              services.AddCors(opt =&gt;
              {
                  opt.AddPolicy(&quot;CorsPolicy&quot;, policy =&gt;
                  {
  
                      policy.AllowAnyMethod().AllowAnyHeader().WithOrigins(&quot;http://localhost:3000&quot;);
  
  
                  });
              });
  
              services.AddMediatR(typeof(List.Handler).Assembly);
              services.AddAutoMapper(typeof(MappingProfiles).Assembly);
              services.AddScoped&lt;IUserAccessor, UserAccessor &gt;();
              services.AddScoped&lt;IPhotoAccessor, PhotoAccessor&gt;();
              services.Configure&lt;CloudinarySettings&gt;(Configuration.GetSection(&quot;Cloudinary&quot;));
  
              return services;
  
          }
  </code></pre>
  <p>But for example if you have hundreds of services. IS that not overloading the application in the start phase?</p>
  <p>Because all the services will initialized in the beginning.</p>
  <p>Is there not a way just to initialise some services when they will directly been called.</p>
  <p>Like lazy loading</p>
  <p>Thank you</p>