Example #1
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                try
                {
                    var context = scope.ServiceProvider.GetService <IVCompareDbContext>();

                    var concreteContext = (VCompareDbContext)context;
                    concreteContext.Database.Migrate();
                    VCompareInitializer.Initialize(concreteContext);
                    var logger = scope.ServiceProvider.GetRequiredService <ILogger <Program> >();
                    logger.LogDebug("Test");
                }
                catch (Exception ex)
                {
                    var logger = scope.ServiceProvider.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while migrating or initializing the database.");
                }
            }

            host.Run();
        }
Example #2
0
 public static void InitializeDbForTests(VCompareDbContext context)
 {
     VCompareInitializer.Initialize(context);
 }