/
diev
/
RepofDocs
Обзор
Документация
Войти
/
diev
/
RepofDocs
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
Rosd/Program.cs
50 строк
1 KB
Dmitrii Evdokimov
Add SeedData
12 янв 2022, 22:15
12 янв 2022, 22:15
4a3ef25
Код
Авторство
О чём код?
using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Rosd.Data; using Rosd.Models; var builder = WebApplication.CreateBuilder(args); // If exception here, disable docker-compose V2 and rebuild the solution. // Add services to the container. var connectionString = builder.Configuration.GetConnectionString("DefaultConnection"); builder.Services.AddDbContext<ApplicationDbContext>(options => // options.UseSqlServer(connectionString)); // Microsoft SQL options.UseNpgsql(connectionString)); // PostgreSQL builder.Services.AddDatabaseDeveloperPageExceptionFilter(); builder.Services.AddDefaultIdentity<IdentityUser<Guid>>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores<ApplicationDbContext>(); builder.Services.AddRazorPages(); var app = builder.Build(); using (var scope = app.Services.CreateScope()) { var services = scope.ServiceProvider; await SeedData.InitializeAsync(services); } // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.MapRazorPages(); app.Run();