Esempio n. 1
0
        public static void InjectAppDBContext(this IServiceCollection services, KRFDatabases databaseSettings = null)
        {
            //Context inject
            services.InjectDBContext <HomepageDBContext>(databaseSettings);

            //Inject database query handlers
            services.AddScoped(s => new Lazy <IHomepageDatabaseQuery>(() => new HomepageDatabaseQuery(s.GetService <HomepageDBContext>())));
            services.AddScoped(s => new Lazy <ITranslationsDatabaseQuery>(() => new TranslationsDatabaseQuery(s.GetService <HomepageDBContext>())));
        }
Esempio n. 2
0
 public static void ConfigureAppDBContext(this IApplicationBuilder app, KRFDatabases databaseSettings = null)
 {
     //Inject Migration Automation
     if (databaseSettings != null && databaseSettings.EnableAutomaticMigration)
     {
         using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
         {
             serviceScope.ConfigureAutomaticMigrations <HomepageDBContext>();
         }
     }
 }