使用 DbPerTenantConnectionStringResolver

using DbPerTenantConnectionStringResolver

使用核心样板框架 3.3.2(我能看到的最新文档是 3.2.1)。

所以我正在尝试实现 db/tenant 配置。

令我高兴的是,我看到实际上有一个名为 DbPerTenantConnectionStringResolver 的 class - 太棒了!

在我的 EntityFrameworkModule 中,我通过添加以下行添加到 override PreInitialize() 方法:

Configuration.ReplaceService<IConnectionStringResolver, DbPerTenantConnectionStringResolver>(DependencyLifeStyle.Transient);

然而这并不能编译:

The non-generic method 'IAbpStartupConfiguration.ReplaceService(Type, Action)' 

cannot be used with type arguments  CCRE.EntityFrameworkCore

希望有人能让我走上正轨...

添加以下命名空间:

using Abp.Configuration.Startup;

访问 this extension method:

public static void ReplaceService<TType, TImpl>(this IAbpStartupConfiguration configuration, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)
    where TType : class
    where TImpl : class, TType
{
    configuration.ReplaceService(typeof(TType), () =>
    {
        configuration.IocManager.Register<TType, TImpl>(lifeStyle);
    });
}