tuitio/IdentityServer.Domain.Data/DependencyInjectionExtensio...

27 lines
966 B
C#
Raw Normal View History

2020-12-20 00:18:53 +02:00
using IdentityServer.Domain.Data.DbContexts;
using IdentityServer.Domain.Data.Repositories;
using IdentityServer.Domain.Repositories;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
namespace IdentityServer.Domain.Data
{
public static class DependencyInjectionExtensions
{
public static void AddDataAccess(this IServiceCollection services)
{
services.AddScoped<IIdentityRepository, IdentityRepository>();
services
.AddDbContextPool<IdentityDbContext>(
(serviceProvider, options) =>
{
var configuration = serviceProvider.GetService<IConfiguration>();
var connectionString = configuration.GetConnectionString("DatabaseConnection");
options.UseSqlServer(connectionString);
});
}
}
}