source: PostgreSqlDotnetCore/Program.cs@ e9bb9d1

main
Last change on this file since e9bb9d1 was 2639fab, checked in by ElenaMoskova <elena.moskova99@…>, 6 weeks ago

Update with triggers

  • Property mode set to 100644
File size: 1.3 KB
Line 
1using Microsoft.AspNetCore.Identity;
2using Microsoft.EntityFrameworkCore;
3using PostgreSqlDotnetCore.Data;
4using PostgreSqlDotnetCore.Models;
5
6var builder = WebApplication.CreateBuilder(args);
7
8// Add services to the container.
9var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
10builder.Services.AddDbContext<ApplicationDbContext>(options =>
11 options.UseNpgsql(connectionString));
12builder.Services.AddDatabaseDeveloperPageExceptionFilter();
13
14builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
15 .AddEntityFrameworkStores<ApplicationDbContext>();
16builder.Services.AddControllersWithViews();
17
18var app = builder.Build();
19
20// Configure the HTTP request pipeline.
21if (app.Environment.IsDevelopment())
22{
23 app.UseMigrationsEndPoint();
24}
25else
26{
27 app.UseExceptionHandler("/Home/Error");
28 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
29 app.UseHsts();
30}
31
32app.UseHttpsRedirection();
33app.UseStaticFiles();
34
35app.UseRouting();
36
37app.UseAuthorization();
38
39app.MapControllerRoute(
40 name: "default",
41 pattern: "{controller=Home}/{action=Index}/{id?}");
42app.MapRazorPages();
43
44app.Run();
Note: See TracBrowser for help on using the repository browser.