Ends in:
4 DAYS
10 HRS
24 MIN
37 SEC
Ends in:
4 D
10 H
24 M
37 S
Open Closed

Error EFCoreRepository doesn't get registered to dependency injection ABP v7.0.3 #4743


User avatar
0
p.j.keukens created
  • ABP Framework version: v7.0.3
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC): yes / no
  • Exception message and stack trace:
  • An exception was thrown while activating Castle.Proxies.ReferenceDataProxy. Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.ReferenceDataProxy. ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Castle.Proxies.ReferenceDataProxy' can be invoked with the available services and parameters: Cannot resolve parameter 'ReferenceData.IReferenceDataRepository referenceDataRepository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], ReferenceData.IReferenceDataRepository)'.
  • Steps to reproduce the issue: Steps to reproduce:
  1. Have a tiered application using MVC and Ef-Core based on the application template
  2. Add a module and reference is from the main project
  3. In the EntityFrameworkCore project of the module add an entity and a repository class
  4. In the Domain project of the module add an interface
  5. In the Application module of the module create an AppService where the custom repository is injected
  6. Some how it cannot resolve the repository and I can't find the problem, if I use IRepository<ReferenceData, string> directly in the AppService that works. But what am I missing that the custom repository isn't registered in the dependency Injection?

Here are the code definitions used:

//Repository in EntityFrameworkCore project of application module
public class EfCoreReferenceDataRepository : EfCoreRepository<ReferenceDbContext, ReferenceData, string>, IReferenceDataRepository
{
	public EfCoreReferenceDataRepository(IDbContextProvider<ReferenceDbContext> dbContextProvider)
		: base(dbContextProvider)
	{
	}
}

//Interface in Domain module of application module (Also tried IRepository<ReferenceData, string> also tried adding ITransientDependency)
public interface IReferenceDataRepository : IBasicRepository<ReferenceData, string>

// Dependency injection in AppService of application module
public ReferenceDataAppService(IReferenceDataRepository referenceDataRepository)

In other modules in the project this works fine, these modules have been upgraded from version 6.0.5 to 7.0.3. The module with the problem is added to the application as a new v7.0.3 module.

I do not use: SkipAutoServiceRegistration

Documentation says: Some specific types are registered to dependency injection by default. Examples:

Repositories (implement BasicRepositoryBase class or its subclasses) are registered as transient.

4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share the project with me? liming.ma@volosoft.com

  • User Avatar
    0
    p.j.keukens created

    @maliming just send you a freshly created project with the same problem.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Rename EfCoreReferenceDataRepository to EfCoreTempReferenceDataRepository

  • User Avatar
    0
    p.j.keukens created

    Ah yeah, stupid mistake by me... Thanks

Made with ❤️ on ABP v9.1.0-preview. Updated on December 02, 2024, 12:35