Hi, I've developed a plugin module that is successfully loaded by Abp. (dotnetcore) I made a different dbcontext and I can use IRepository<myentity> and also IRepository<RolePermisionSetting>, but I'm unable to use IRepository<Role> . There is alway an error of DI. How can I use in my outer module all the security/admin stuff of abp.zero ?
Thanks
5 Answer(s)
-
0
Hi,
Can you share your DbContext definition ?
Thanks.
-
0
Shure, it's very simple. Only one table CuwPermission. I wuold like to use IRepository<Role>, IRepository<User>, and so on.
public class CartellaUtenteWebContext: AbpDbContext { public virtual DbSet<CuwPermission> CuwPermissions { get; set; }
/* Default constructor is needed for EF command line tool. */ public CartellaUtenteWebContext() : base(GetConnectionString()) { }
.... omitted ctors code
DomainService where I need Role Repository:
public class CuwRoleDomainService: DomainService, ICuwRoleDomainService { private readonly IRepository<Role> roleRepository; public CuwRoleDomainService(IRepository<Role> roleRepository) { this.roleRepository = roleRepository; }
public async Task<Role> GetRoleAsync(int roleId) { var result = await roleRepository.FirstOrDefaultAsync(roleId); return result; } }
Thanks
-
0
Hi,
Your DbContext seems fine. Normally User and Role entities are defined in your Core module, did you add a reference to core module to your plugin module ?
-
0
Hi,
The module is outside of abpzero template solution (host). The scenario is that many developers build their own plugins and at the end all plugins are deployed on a remote server. Nobody can access to the host solutions.
I've resolved in this manner :
- created a nuget package from abpzero core module.
- referenced this package on our core plugin module
- set DependsOn to abpzero core module
It seems to work fine and when you improve abpzero template, we need only to upgrade the nuget package.
Do you think is a correct way ?
-
0
Hi,
This is the best solution at the moment I think :).