Added database models
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
using HopFrame.Web;
|
||||
using Portfolio.Api;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
@@ -5,6 +8,15 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddOpenApi();
|
||||
builder.AddServiceDefaults();
|
||||
|
||||
builder.AddNpgsqlDbContext<DatabaseContext>("data");
|
||||
|
||||
builder.Services.AddHopFrame(options => {
|
||||
options.DisplayUserInfo(false);
|
||||
options.AddDbContext<DatabaseContext>();
|
||||
});
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
@@ -12,7 +24,17 @@ if (app.Environment.IsDevelopment()) {
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
await using (var scope = app.Services.CreateAsyncScope()) {
|
||||
var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
||||
await db.Database.EnsureCreatedAsync();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.MapDefaultEndpoints();
|
||||
|
||||
app.UseAntiforgery();
|
||||
app.MapStaticAssets();
|
||||
app.MapRazorComponents<App>()
|
||||
.MapHopFramePages();
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user