// Copyright (c) HelloShop Corporation. All rights reserved. // See the license file in the project root for more information. using MultiTenancySample.DatabaseIsolationService.EntityFrameworks; using MultiTenancySample.ServiceDefaults; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddDbContextFactory(lifetime: ServiceLifetime.Scoped); builder.Services.AddScoped(); builder.Services.AddHttpContextAccessor(); builder.Services.AddMultiTenancy(); var app = builder.Build(); app.UseMultiTenancy(); var serviceProvider = app.Services.CreateScope().ServiceProvider; var dataSeeding = serviceProvider.GetRequiredService(); await dataSeeding.SeedDataAsync(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();