Asp.Net_Single_Page_App/Single_Page_Anwendung/Program.cs

45 lines
1.3 KiB
C#
Raw Normal View History

2022-05-16 12:46:57 +02:00
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
2022-05-16 12:46:57 +02:00
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Single_Page_Anwendung.Models;
2022-05-16 12:46:57 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Aps_Single_Page_Anwendung
{
public class Program
{
public static void Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
using(var scope = host.Services.CreateScope())
{
var service = scope.ServiceProvider;
try
{
DatenEinlesen.Initialize(service);
}
catch (Exception ex)
{
var logger = service.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "Fehler mit der Datenbank!");
throw;
}
}
host.Run();
2022-05-16 12:46:57 +02:00
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}