27 lines
985 B
C#
27 lines
985 B
C#
|
using Microsoft.EntityFrameworkCore;
|
|||
|
using Microsoft.Extensions.Configuration;
|
|||
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
using NetworkResurrector.Agent.Domain.Data.DbContexts;
|
|||
|
using NetworkResurrector.Agent.Domain.Data.Repositories;
|
|||
|
using NetworkResurrector.Agent.Domain.Repositories;
|
|||
|
|
|||
|
namespace NetworkResurrector.Agent.Domain.Data
|
|||
|
{
|
|||
|
public static class DependencyInjectionExtensions
|
|||
|
{
|
|||
|
public static void AddDataAccess(this IServiceCollection services)
|
|||
|
{
|
|||
|
services.AddScoped<IAgentRepository, AgentRepository>();
|
|||
|
|
|||
|
services
|
|||
|
.AddDbContextPool<AgentDbContext>(
|
|||
|
(serviceProvider, options) =>
|
|||
|
{
|
|||
|
var configuration = serviceProvider.GetService<IConfiguration>();
|
|||
|
var connectionString = configuration.GetConnectionString("DatabaseConnection");
|
|||
|
options.UseSqlServer(connectionString);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|