我如何/在哪里注册IDbPerTenantConnectionStringResolver

时间:2017-11-20 05:40:28

标签: aspnetboilerplate

尝试运行核心api主机。我在EntityFrameworkModule

中有这个
    public override void PreInitialize()
{
    Configuration.MultiTenancy.IsEnabled = true;`

   // CONNECTION STRING RESOLVER
    Configuration.ReplaceService<IConnectionStringResolver, DbPerTenantConnectionStringResolver>(DependencyLifeStyle.Transient);

    Configuration.DefaultNameOrConnectionString = MyConsts.DefaultConnectionStringName;

    if (!SkipDbContextRegistration)
    {
        //DEFAULT
        Configuration.Modules.AbpEfCore().AddDbContext<MyContext>(options =>
        {
            if (options.ExistingConnection != null)
                MyContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
            else
                MyContextConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
        });

    }
}

错误

 Mvc.ExceptionHandling.AbpExceptionFilter - Can't create component 'Ccre.EntityFrameworkCore.AbpZeroDbMigrator' as it has dependencies to be satisfied.

'Ccre.EntityFrameworkCore.AbpZeroDbMigrator' is waiting for the following dependencies:
- Service 'Abp.MultiTenancy.IDbPerTenantConnectionStringResolver' which was not registered.

我如何/在何处注册IDbPerTenantConnectionStringResolver

我在Migrator.MigratorModule

PreInitialize中有这一行
Configuration.ReplaceService<IConnectionStringResolver, DbPerTenantConnectionStringResolver>(DependencyLifeStyle.Transient);

以及EntityFrameworkModule

0 个答案:

没有答案