public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { try { var context = scope.ServiceProvider.GetService <IUserServiceDbContext>(); var concreteContext = (UserServiceDbContext)context; concreteContext.Database.Migrate(); OrdsomeInitializer.Initialize(concreteContext); } catch (Exception ex) { var logger = scope.ServiceProvider.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while migrating or initializing the database."); } } host.Run(); }
public static void InitializeDbForTests(RequestServiceDbContext context) { OrdsomeInitializer.Initialize(context); }