MacGurk / Morphnet.Homebudget

MIT License
0 stars 0 forks source link

Initialize database #1

Open MacGurk opened 1 year ago

MacGurk commented 1 year ago

If the database does not exist, it should be created using the EF Core migrations

MacGurk commented 11 months ago

Database is currently initialized on runtime in Program.cs.

using (var scope = app.Services.CreateScope())
{
    var context = scope.ServiceProvider.GetRequiredService<HomeBudgetContext>();
    context.Database.Migrate();
}

Not ideal, as it is not recommended in production code as of Microsoft: https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/applying?tabs=dotnet-core-cli#apply-migrations-at-runtime