Files
DbFirst/DbFirst.Infrastructure/DependencyInjection.cs
OlgunR 05825b6815 Refactor DI: move repository registrations to Infrastructure
Centralize repository service registrations in Infrastructure's
DependencyInjection.cs for better maintainability and separation
of concerns. Remove direct registrations from Program.cs and
add necessary using statements.
2026-04-20 16:28:37 +02:00

27 lines
1.0 KiB
C#

using DbFirst.Application.Repositories;
using DbFirst.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace DbFirst.Infrastructure;
public static class DependencyInjection
{
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
{
services.Configure<TableConfigurations>(configuration.GetSection("TableConfigurations"));
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")));
services.AddDbContext<MassDataDbContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("MassDataConnection")));
services.AddScoped<ICatalogRepository, CatalogRepository>();
services.AddScoped<IMassDataRepository, MassDataRepository>();
services.AddScoped<ILayoutRepository, LayoutRepository>();
return services;
}
}