🐛 Ensure that migrations run

Co-authored-by: haraldnilsen <harald_998@hotmail.com>
This commit is contained in:
Sindre Kjelsrud 2023-10-03 10:56:14 +02:00
parent 187c669495
commit f9b4309072

View file

@ -36,11 +36,8 @@ var services = builder.Services.BuildServiceProvider();
using (var scope = services.CreateScope())
{
var context = scope.ServiceProvider.GetRequiredService<MovieDbContext>();
if (context.Database.EnsureCreated())
{
context.Database.Migrate();
}
context.Database.EnsureDeleted(); // cursed
context.Database.Migrate();
// Check if movies are already inserted to avoid duplicate insertion
if (!context.Movies.Any())