public void ConfigureProductionServices(IServiceCollection services) { var builder = new PostgresqlConnectionStringBuilder(Configuration["DATABASE_URL"]) { Pooling = true, TrustServerCertificate = true, SslMode = SslMode.Require }; services.AddEntityFrameworkNpgsql().AddDbContext <ApplicationDbContext>(options => options.UseNpgsql(builder.ConnectionString)); ConfigureServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var builder = new PostgresqlConnectionStringBuilder(Environment.GetEnvironmentVariable("DATABASE_URL")) { Pooling = true, TrustServerCertificate = true, SslMode = SslMode.Require }; services.AddDbContext <ApplicationDbContext>(options => options.UseNpgsql(builder.ConnectionString, x => x.MigrationsAssembly("Portfolio.Infrastructure"))); services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddAutoMapper(typeof(AutoMapperProfile)); services.AddScoped <IUnitOfWork, UnitOfWork>(); }