28 lines
966 B
C#
28 lines
966 B
C#
using DD.Persistence.Database.Entity;
|
|
using DD.Persistence.Database.Postgres.Repositories;
|
|
using DD.Persistence.Database.Postgres.RepositoriesCached;
|
|
using DD.Persistence.Models;
|
|
using DD.Persistence.Repositories;
|
|
using Mapster;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System.Reflection;
|
|
|
|
namespace DD.Persistence.Database.Model;
|
|
|
|
public static class DependencyInjection
|
|
{
|
|
public static IServiceCollection AddPersistenceDbContext(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
string connectionStringName = "DefaultConnection";
|
|
|
|
services.AddDbContext<PersistencePostgresContext>(options =>
|
|
options.UseNpgsql(configuration.GetConnectionString(connectionStringName)));
|
|
|
|
services.AddScoped<DbContext>(provider => provider.GetRequiredService<PersistencePostgresContext>());
|
|
|
|
return services;
|
|
}
|
|
}
|