Fungerande version av skiktad lösning Winforms App med SQlite och entity framework
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
using DIDemoLib;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using WinFormDiApp.DAL;
|
||||
using WinFormDiApp.DAL.Data;
|
||||
|
||||
namespace WinFormDi
|
||||
{
|
||||
@ -10,15 +12,19 @@ namespace WinFormDi
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var host = ContainerConfig.Configure();
|
||||
var host = ContainerConfig.Configure(CreateHostBuilder(args));
|
||||
|
||||
using var scope = host.Services.CreateScope();
|
||||
|
||||
try
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
|
||||
var context = services.GetRequiredService<ApplicationDbContext>();
|
||||
DataSeeder.Initialize(context);
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
@ -32,5 +38,11 @@ namespace WinFormDi
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user