Open Closed

Problem Seeding Localization data for MongoDb microservice. #4732


User avatar
0
ndeol created
  • ABP Framework version: v7.0.3 Microservices Commercial template
  • UI type: Angular
  • DB provider: MongoDB
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"
  • Create new microservice Converted it to mongodb using this guide https://docs.abp.io/en/commercial/latest/guides/microservice-mongodb

When I try to seed Localization data to administration microservice database I get this exception.

[09:17:53 ERR] Sequence contains more than one element
System.InvalidOperationException: Sequence contains more than one element
   at System.Linq.ThrowHelper.ThrowMoreThanOneElementException()
   at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
   at MongoDB.Driver.AsyncCursorHelper.SingleOrDefaultAsync[T](Task`1 cursorTask, CancellationToken cancellationToken)
   at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository`2.FindAsync(Expression`1 predicate, Boolean includeDetails, CancellationToken cancellationToken)
   at Volo.Abp.LanguageManagement.MongoDB.MongoLocalizationResourceRecordRepository.FindAsync(String name, CancellationToken cancellationToken)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Volo.Abp.LanguageManagement.External.ExternalLocalizationSaver.LkSwGYsliR(SaveContext  , LocalizationResource  , String[]  )
   at Volo.Abp.LanguageManagement.External.ExternalLocalizationSaver.rJYwS5QxcO(SaveContext  , LocalizationResource  )
   at Volo.Abp.LanguageManagement.External.ExternalLocalizationSaver.SaveAsync()
   at Volo.Abp.LanguageManagement.External.ExternalLocalizationSaver.SaveAsync()
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync()
   at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Volo.Abp.LanguageManagement.LanguageManagementDomainModule.<>c__DisplayClass6_1.dqYSTJLxrtjUOO4OmDO.MoveNext()

But if I remove AbpLocalizationResources Resource collection and Run new microservice first Data is seeded to AbpLocalizationResources and Localization works fine.

Also another issue is I am unable to overwrite localization strings for OpenIddict Module . I used this guide https://docs.abp.io/en/abp/7.0/Localization to overwrite .


5 Answer(s)
  • User Avatar
    0
    ndeol created

    Is there any documentation for this seeding (permission and localization) data for microservices using administration service db connection string.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    When I try to seed Localization data to administration microservice database I get this exception.

    Can you share your steps and code?

    Also another issue is I am unable to overwrite localization strings for OpenIddict Module . I used this guide https://docs.abp.io/en/abp/7.0/Localization to overwrite .

    We have a sample. https://github.com/abpframework/abp-samples/tree/master/DocumentationSamples/ExtendLocalizationResource

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Is there any documentation for this seeding (permission and localization) data for microservices using administration service db connection string.

    At present, you can refer to these two documents.

    https://docs.abp.io/en/abp/latest/Data-Seeding https://docs.abp.io/en/abp/latest/Connection-Strings

  • User Avatar
    0
    ndeol created

    I am trying to seed permission and localization data from microservice to administration service Db for microservice project. There should be some documentation how this ExternalLocalizer works and why I see that exception when I use LanguageManagementDataSeeder to seed Language data . Do you have any document how your manage permission and localization in distributed scenario. We are using comerical microservice template but with MongoDB.

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    There was an issue about OpenIddict localization is located in different layer causing localization of OpenIddict not working and not able to override. That issue is fixed and will be available in the next release.

    For seeding permissions, you can inject IPermissionDataSeeder in the your microservice data seeder. Please examine the IdentityServiceDataSeeder under the IdentityService.HttpApi.Host. You can create a similar data seeder and inject it to the DatabaseMigrationCheckerto seed it after database migration.

    [09:17:53 ERR] Sequence contains more than one element

    This error is about duplicate key trying to get inserted. It may happen because of the race conditions. It is not important, eventually it will be inserted and consistent.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09