Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        // 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>();
        }