-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
35 lines (31 loc) · 914 Bytes
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using FastCost.DAL;
using FastCost.Services;
using Microsoft.EntityFrameworkCore;
namespace FastCost;
public partial class App : Application
{
public App(IServiceProvider serviceProvider, IAllCostsService allCostsService)
{
InitializeComponent();
InitializeDatabase(serviceProvider);
}
private void InitializeDatabase(IServiceProvider serviceProvider)
{
try
{
using (var scope = serviceProvider.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<AppDbContext>();
dbContext.Database.Migrate();
}
}
catch (Exception ex)
{
Console.WriteLine($"Error creating database: {ex.Message}");
}
}
protected override Window CreateWindow(IActivationState activationState)
{
return new Window(new AppShell());
}
}