Example #1
0
        public static IServiceCollection AddDbPerSchema <TDbContext>(this IServiceCollection services,
                                                                     DbIntegrationType dbType, string key = "default",
                                                                     string connectionName = "tenantConnection",
                                                                     Action <DbContextOptionsBuilder> optionAction = null)
            where TDbContext : DbContext, ITenantDbContext
        {
            var settings = new TenantSettings <TDbContext>()
            {
                Key                   = key,
                DbType                = dbType,
                ConnectionName        = connectionName,
                ConnectionType        = ConnectionResolverType.BySchema,
                DbContextOptionAction = optionAction
            };

            return(services.AddTenantedDatabase <TDbContext>(settings));
        }
        public static IServiceCollection AddDbPerConnection <TDbContext>(this IServiceCollection services,
                                                                         DbIntegrationType dbType, string key = "default",
                                                                         string connectionPrefix = "tenanted",
                                                                         Action <DbContextOptionsBuilder> optionAction = null,
                                                                         Action <IServiceProvider, string, DbContextOptionsBuilder> dbContextSetup = null)
            where TDbContext : DbContext, ITenantDbContext
        {
            var settings = new TenantSettings <TDbContext>()
            {
                Key                   = key,
                DbType                = dbType,
                ConnectionPrefix      = connectionPrefix,
                ConnectionType        = ConnectionResolverType.ByDatabase,
                DbContextOptionAction = optionAction,
                DbContextSetup        = dbContextSetup
            };

            return(services.AddTenantedDatabase <TDbContext>(settings));
        }