Open Closed

How to use Domain Service in DataSeedContributor (DbMigrator)? #6169


User avatar
0
mert.kir created
  • ABP Framework version: v6.0.3
  • UI Type: Angular
  • Database System: EF Core (SQL Server, PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes

When I try to reach the Domain Service with the Service Provider in DataSeedContributor, I get the error as follows. How can I use Domain Service methods in the DataSeedContributor class?

Autofac.Core.DependencyResolutionException: An exception was thrown while activating Example.Project.Entities.EntityDomainService. ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Example.Project.Entities.EntityDomainService' can be invoked with the available services and parameters:


5 Answer(s)
  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Share your domain service?

    It seems it is not registered to DI, perhaps you forgot to extend the DomainService base class.

  • User Avatar
    0
    mert.kir created

    Share your domain service?

    It seems it is not registered to DI, perhaps you forgot to extend the DomainService base class.

    I use Abp's DomainServiceand IDomainServiceclasses as base. There is no problem while the Http API project is running. But the DbMigrator project cannot resolve DI. Because DbMigrator cannot access the Domain layer by default.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please share the full error stack and the code of EntityDomainService

    Thanks.

  • User Avatar
    0
    mert.kir created

    hi

    Please share the full error stack and the code of EntityDomainService

    Thanks.

    Hi

    I share the codes in a masked form. If you need a clear version and more details, I can send it via e-mail or private ticket.

    There is no problem when calling the following DomainService from AppService. However, from within DbMigrator _serviceProvider.GetRequiredService<IEntityDomainService>(); When called like this, an error is received.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    liming.ma@volosoft.com

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