protected virtual void CreateOrMigrate(Tenant tenant, Action <TDbContext> seedAction) { var args = new DbPerTenantConnectionStringResolveArgs( tenant == null ? (int?)null : (int?)tenant.Id, tenant == null ? MultiTenancySides.Host : MultiTenancySides.Tenant ); args["DbContextType"] = typeof(TDbContext); args["DbContextConcreteType"] = typeof(TDbContext); var nameOrConnectionString = ConnectionStringHelper.GetConnectionString( ConnectionStringResolver.GetNameOrConnectionString(args) ); using (var uow = UnitOfWorkManager.Begin(TransactionScopeOption.Suppress)) { using (var dbContext = DbContextResolver.Resolve <TDbContext>(nameOrConnectionString, null)) { dbContext.Database.Migrate(); seedAction?.Invoke(dbContext); UnitOfWorkManager.Current.SaveChanges(); uow.Complete(); } } }
protected virtual string ResolveConnectionString(ConnectionStringResolveArgs args) { return(ConnectionStringResolver.GetNameOrConnectionString(args)); }
protected virtual string ResolveConnectionString(Dictionary <string, object> arg) { return(ConnectionStringResolver.GetNameOrConnectionString(arg)); }
protected virtual string ResolveConnectionString(ref string schema) { return(ConnectionStringResolver.GetNameOrConnectionString(ref schema)); }