Ejemplo n.º 1
0
 private void _DoAutomaticDbMigration(IApplicationBuilder app)
 {
     using (var sScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
     {
         PaymentAppContext context = sScope.ServiceProvider.GetRequiredService <PaymentAppContext>();
         context.Database.Migrate();
     }
 }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PaymentAppContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment v1"));
            }

            app.UseRouting();

            app.UseAuthorization();

            context.Database.Migrate();

            app.UseEndpoints(endpoints => {
                endpoints.MapControllers();
            });
        }