I am trying to register repositories in a separate module called freeswitch via ABP Framework.
Interface is IFSExtensionRepository
context.Services.AddAbpDbContext<FreeswitchDBContext>(options =>
{
options.AddRepository<FSExtension, EfCoreExtensionRepository>();
});
Freeswitch DB Context
[ConnectionStringName(FreeswitchDbProperties.ConnectionStringName)]
public class FreeswitchDbContext : AbpDbContext<FreeswitchDbContext>, IFreeswitchDbContext
{
/* Add DbSet for each Aggregate Root here. Example:
* public DbSet<Question> Questions { get; set; }
*/
public DbSet<FSExtension> Extension { get; set; }
public FreeswitchDbContext(DbContextOptions<FreeswitchDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.ConfigureFreeswitch();
}
}
Repository
public class ExtensionRepositoryEf : EfCoreRepository<IFreeswitchDbContext, FSExtension, Guid>, IFSExtensionRepository
{
private readonly ICurrentTenant CurrentTenant;
public ExtensionRepositoryEf(IDbContextProvider<IFreeswitchDbContext> dbContextProvider, ICurrentTenant currentTenant) : base(dbContextProvider)
{
CurrentTenant = currentTenant;
}
public virtual async Task<FSExtension> FindByNameAsync(string extensionName, CancellationToken canceltoken = default)
{
return await (await GetDbSetAsync())
.OrderBy(t => t.Id)
.FirstOrDefaultAsync(t => t.ExtensionNumber.ToLower() == extensionName.ToLower() && t.TenantId == CurrentTenant.Id, GetCancellationToken(canceltoken));
}
}
The error I get while calling the class which is injecting IFSExtensionRepository is below
---------- Exception Data ---------- ActivatorChain = Castle.Proxies.RinglurUserServiceProxy -> RinglurNet.Ringlur.RinglurUserManager -> Freeswitch.Service.ExtensionManager
The issue is resolved when I use the following code
context.Services.AddTransient<IFSExtensionRepository, ExtensionRepositoryEf>();