Created database
This commit is contained in:
parent
e068536abe
commit
eec8e419ba
19 changed files with 618 additions and 4 deletions
|
@ -1,13 +1,21 @@
|
|||
using Discord.OAuth2;
|
||||
using Discord.OAuth2;
|
||||
using Lieb.Data;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
|
||||
builder.Services.AddDbContext<LiebContext>(options =>
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("LiebContext")));
|
||||
|
||||
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
||||
|
||||
builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddAuthentication(opt =>
|
||||
{
|
||||
|
@ -33,7 +41,20 @@ if (!app.Environment.IsDevelopment())
|
|||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseMigrationsEndPoint();
|
||||
}
|
||||
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
|
||||
var context = services.GetRequiredService<LiebContext>();
|
||||
context.Database.EnsureCreated();
|
||||
DbInitializer.Initialize(context);
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue