I haved created a simple ASP.NET Core 6 mvc app. Then Here's my Program.cs

I would like to know if ever I have to many services and repositories, can I bundle service and repo and call it here?
Yes, to do so, you need to have a new class called for example AddRepositories or AddServices which will be looking something like that:
public static IServiceCollection AddRepositories(this IServiceCollection services)
{
services.AddScoped<IClientRepository, ClientRepository>();
services.AddScoped<IProductRepository, ProductRepository>();
return services;
}
then in Program.cs you need to attach that bundle by adding this line:
builder.Services.AddRepositories();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With