persistence/DD.Persistence.Database.Postgres/DependencyInjection.cs
Olga Nemt d90b72b14e 1. Исправлены namespaces.
2. Добавлен проект DD.Persistence.App со всеми необходимыми настройками
2024-12-16 15:38:46 +05:00

21 lines
712 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
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;
}
}