public static void Main(string[] args) { // Get the IHost which will host this application. var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { // Get the instance of DbContext var services = scope.ServiceProvider; var context = services.GetRequiredService <ApiDbContext>(); // Call the PortIn to create port in data PortIn.Initialize(services); } // Continue to run the application host.Run(); }