public QksDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <QksDbContext>(); var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder()); QksDbContextConfigurer.Configure(builder, configuration.GetConnectionString(QksConsts.ConnectionStringName)); return(new QksDbContext(builder.Options)); }
public override void PreInitialize() { //Configuration.ReplaceService(typeof(IConnectionStringResolver), () => //{ // IocManager.IocContainer.Register( // Component.For<IConnectionStringResolver>() // .ImplementedBy<MyConnectionStringResolver>() // .LifestyleTransient() // ); //}); Configuration.ReplaceService(typeof(IConnectionStringResolver), () => { IocManager.IocContainer.Register( Component.For <IConnectionStringResolver, IDbPerTenantConnectionStringResolver>() .ImplementedBy <MyDbPerTenantConnectionStringResolver>() .LifestyleTransient() ); }); if (!SkipDbContextRegistration) { Configuration.Modules.AbpEfCore().AddDbContext <QksDbContext>(options => { if (options.ExistingConnection != null) { QksDbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection); } else { QksDbContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString); } }); //if (_pluginOpt.Loaded) PluginEFCoreInit(); } }