Hello I want to get all the User Role Org entities from IdentityDbContext in my .*EntityFrameworkCore project How can I achieve that? thanks~ or are there User Role Org cache in Redis ?
28 Answer(s)
-
0
hi
You can use Repository to get entities.
https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs
https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs
-
0
-
0
hi
You cannot use identity-related dbcontext and repository in your repository methods, you can use them in domain or application services.
var users = IdentityUserRepository.GetAll() var mailRecive = mailReciveRepository.GetAll() var foo = mailRecive.where(user.xxx)
-
0
-
0
Yes, Something like this.
-
0
I added the Volo.Abp.Identity.Domain to my application project. get error after call the method/ what do I miss?
[oaservice_6dfbae7e-7]: [16:30:21 ERR] ---------- RemoteServiceErrorInfo ---------- [oaservice_6dfbae7e-7]: { [oaservice_6dfbae7e-7]: "code": null, [oaservice_6dfbae7e-7]: "message": "对不起,在处理你的请求期间,产生了一个服务器内部错误!", [oaservice_6dfbae7e-7]: "details": null, [oaservice_6dfbae7e-7]: "data": { [oaservice_6dfbae7e-7]: "ActivatorChain": "CP.OaService.Controllers.Mails.MailController -> CP.OaService.Mails.MailsAppService" [oaservice_6dfbae7e-7]: }, [oaservice_6dfbae7e-7]: "validationErrors": null [oaservice_6dfbae7e-7]: } [oaservice_6dfbae7e-7]: [oaservice_6dfbae7e-7]: [16:30:21 ERR] An exception was thrown while activating CP.OaService.Controllers.Mails.MailController -> CP.OaService.Mails.MailsAppService. [oaservice_6dfbae7e-7]: Autofac.Core.DependencyResolutionException: An exception was thrown while activating CP.OaService.Controllers.Mails.MailController -> CP.OaService.Mails.MailsAppService. [oaservice_6dfbae7e-7]: ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'CP.OaService.Mails.MailsAppService' can be invoked with the available services and parameters: [oaservice_6dfbae7e-7]: Cannot resolve parameter 'Volo.Abp.Identity.IIdentityUserRepository identityUserRepository' of constructor 'Void .ctor(CP.OaService.Mails.IMailRepository, Volo.Abp.Identity.IIdentityUserRepository)'. [oaservice_6dfbae7e-7]: at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable
1 parameters) [oaservice_6dfbae7e-7]: at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable
1 parameters) [oaservice_6dfbae7e-7]: at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action1 next) [oaservice_6dfbae7e-7]: at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action
1 next) [oaservice_6dfbae7e-7]: at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action
1 next) [oaservice_6dfbae7e-7]: at Autofac.Extras.DynamicProxy.RegistrationExtensions.<>c__DisplayClass8_03.<EnableInterfaceInterceptors>b__1(ResolveRequestContext ctxt, Action
1 next) [oaservice_6dfbae7e-7]: at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) [oaservice_6dfbae7e-7]: --- End of inner exception stack trace --- [oaservice_6dfbae7e-7]: at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action
1 next) [oaservice_6dfbae7e-7]: at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) [oaservice_6dfbae7e-7]: at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action
1 next) [oaservice_6dfbae7e-7]: at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) [oaservice_6dfbae7e-7]: at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) [oaservice_6dfbae7e-7]: at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) [oaservice_6dfbae7e-7]: at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable
1 parameters) [oaservice_6dfbae7e-7]: at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext) [oaservice_6dfbae7e-7]: at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass6_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext) [oaservice_6dfbae7e-7]: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) [oaservice_6dfbae7e-7]: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() [oaservice_6dfbae7e-7]: --- End of stack trace from previous location --- [oaservice_6dfbae7e-7]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) -
0
I added the Volo.Abp.Identity.Domain to my application project.
You also need the
Volo.Abp.Identity.EntityFrameworkCore
module. -
0
have added the Volo.Abp.Identity.EntityFrameworkCore.dll but still, get the same error. do I need to add any code?
[oaservice_a9a502b8-e]: [17:10:31 ERR] ---------- RemoteServiceErrorInfo ---------- [oaservice_a9a502b8-e]: { [oaservice_a9a502b8-e]: "code": null, [oaservice_a9a502b8-e]: "message": "对不起,在处理你的请求期间,产生了一个服务器内部错误!", [oaservice_a9a502b8-e]: "details": null, [oaservice_a9a502b8-e]: "data": { [oaservice_a9a502b8-e]: "ActivatorChain": "CP.OaService.Controllers.Mails.MailController -> CP.OaService.Mails.MailsAppService" [oaservice_a9a502b8-e]: }, [oaservice_a9a502b8-e]: "validationErrors": null [oaservice_a9a502b8-e]: } [oaservice_a9a502b8-e]: [oaservice_a9a502b8-e]: [17:10:31 ERR] An exception was thrown while activating CP.OaService.Controllers.Mails.MailController -> CP.OaService.Mails.MailsAppService. [oaservice_a9a502b8-e]: Autofac.Core.DependencyResolutionException: An exception was thrown while activating CP.OaService.Controllers.Mails.MailController -> CP.OaService.Mails.MailsAppService. [oaservice_a9a502b8-e]: ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'CP.OaService.Mails.MailsAppService' can be invoked with the available services and parameters: [oaservice_a9a502b8-e]: Cannot resolve parameter 'Volo.Abp.Identity.IIdentityUserRepository identityUserRepository' of constructor 'Void .ctor(CP.OaService.Mails.IMailRepository, Volo.Abp.Identity.IIdentityUserRepository)'. [oaservice_a9a502b8-e]: at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable
1 parameters) [oaservice_a9a502b8-e]: at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable
1 parameters) [oaservice_a9a502b8-e]: at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action1 next) [oaservice_a9a502b8-e]: at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action
1 next) [oaservice_a9a502b8-e]: at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action
1 next) [oaservice_a9a502b8-e]: at Autofac.Extras.DynamicProxy.RegistrationExtensions.<>c__DisplayClass8_03.<EnableInterfaceInterceptors>b__1(ResolveRequestContext ctxt, Action
1 next) [oaservice_a9a502b8-e]: at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) [oaservice_a9a502b8-e]: --- End of inner exception stack trace --- [oaservice_a9a502b8-e]: at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action
1 next) [oaservice_a9a502b8-e]: at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) [oaservice_a9a502b8-e]: at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action
1 next) [oaservice_a9a502b8-e]: at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) [oaservice_a9a502b8-e]: at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) [oaservice_a9a502b8-e]: at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) [oaservice_a9a502b8-e]: at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable
1 parameters) [oaservice_a9a502b8-e]: at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext) [oaservice_a9a502b8-e]: at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass6_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext) [oaservice_a9a502b8-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) [oaservice_a9a502b8-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() [oaservice_a9a502b8-e]: --- End of stack trace from previous location --- [oaservice_a9a502b8-e]: at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) -
0
Add them to your module depends on attribute.
[DependsOn( typeof(AbpIdentityDomainModule), typeof(AbpIdentityEntityFrameworkCoreModule))]
-
0
AFTER ADDED
[DependsOn( typeof(AbpIdentityDomainModule), typeof(AbpIdentityEntityFrameworkCoreModule))]
Got those errors
No configuration found for Microsoft.EntityFrameworkCore.DbContext,
-
0
[17:25:56 ERR] An exception was thrown while activating Volo.Abp.Identity.EntityFrameworkCore.IdentityDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions
1[[Volo.Abp.Identity.EntityFrameworkCore.IdentityDbContext, Volo.Abp.Identity.EntityFrameworkCore, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null]]. [oaservice_a9a502b8-e]: Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Abp.Identity.EntityFrameworkCore.IdentityDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions
1[[Volo.Abp.Identity.EntityFrameworkCore.IdentityDbContext, Volo.Abp.Identity.EntityFrameworkCore, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null]]. [oaservice_a9a502b8-e]: ---> Volo.Abp.AbpException: No configuration found for Microsoft.EntityFrameworkCore.DbContext, Microsoft.EntityFrameworkCore, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60! Use services.Configure<AbpDbContextOptions>(...) to configure it. [oaservice_a9a502b8-e]: at Volo.Abp.EntityFrameworkCore.DependencyInjection.DbContextOptionsFactory.Configure[TDbContext](AbpDbContextOptions options, AbpDbContextConfigurationContext1 context) [oaservice_a9a502b8-e]: at Volo.Abp.EntityFrameworkCore.DependencyInjection.DbContextOptionsFactory.Create[TDbContext](IServiceProvider serviceProvider) [oaservice_a9a502b8-e]: at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable
1 parameters) [oaservice_a9a502b8-e]: at Autofac.Core.Activators.Delegate.DelegateActivator.<ConfigurePipeline>b__2_0(ResolveRequestContext ctxt, Action1 next) [oaservice_a9a502b8-e]: at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action
1 next) [oaservice_a9a502b8-e]: at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next) [oaservice_a9a502b8-e]: --- End of inner exception stack trace --- -
0
Can you share a private repository on Github? and invite me to the contributor. @maliming
-
0
already added tks
-
0
-
0
Can I ADD [repalcedbcontext(identitydbcontext)] to my .*EntityFrameworkCore project to use the identitydbcontext?
-
0
no
You can use it in
CP.IdentityService
project. -
0
no
You can use it in
CP.IdentityService
project.as you mentioned if I can't use identitydbcontext in my .*EntityFrameworkCore project, so the Identityuser navigation property can't use in my entities of the microservice solution?
-
0
Yes
-
0
-
0
The
List<PORItem>
needs to support serialization by JSON. -
0
https://docs.abp.io/en/abp/latest/Caching I see the IDistributedCache internally serializes/deserializes the cached objects in the doc.
I tested
string json = JsonConvert.SerializeObject(List<PORItem>); is worked fine.
-
0
You can test your caching methods individually.
-
0
-
0
Please use DTO to replace the Entity type.
https://docs.abp.io/en/abp/latest/Data-Transfer-Objects
-
0