abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.48k stars 3.35k forks source link

Can't inject the repository. #20102

Open 1957993455 opened 1 week ago

1957993455 commented 1 week ago
 Volo.Abp.AspNetCore.Mvc.ExceptionHandling.AbpExceptionFilter[0]
      An exception was thrown while activating Blog.Ling.Application.Services.User.UserService -> Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`3[[Ling.Blog.EntityFrameworkCore.BlogDbContext, Ling.Blog.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Blog.Ling.Domain.Entities.UserEntity, Blog.Ling.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Guid, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].
      Autofac.Core.DependencyResolutionException: An exception was thrown while activating Blog.Ling.Application.Services.User.UserService -> Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`3[[Ling.Blog.EntityFrameworkCore.BlogDbContext, Ling.Blog.EntityFrameworkCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Blog.Ling.Domain.Entities.UserEntity, Blog.Ling.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Guid, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].
       ---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`3[Ling.Blog.EntityFrameworkCore.BlogDbContext,Blog.Ling.Domain.Entities.UserEntity,System.Guid]' can be invoked with the available services and parameters:
      Cannot resolve parameter 'Volo.Abp.EntityFrameworkCore.IDbContextProvider`1[Ling.Blog.EntityFrameworkCore.BlogDbContext] dbContextProvider' of constructor 'Void .ctor(Volo.Abp.EntityFrameworkCore.IDbContextProvider`1[Ling.Blog.EntityFrameworkCore.BlogDbContext])'.

这是我efcore的模块代码

[DependsOn(typeof(AbpEntityFrameworkCoreModule),
    typeof(AbpEntityFrameworkCoreMySQLModule))]
public class BlogEfCoreModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        var services = context.Services;
        Configure<AbpDbConnectionOptions>(opt =>
        {
            opt.ConnectionStrings.Default = context.Services.GetConfiguration().GetConnectionString("DefaultConnection");
        });

        services.AddAbpDbContext<BlogDbContext>(opt =>
        {
            opt.AddDefaultRepositories(true);
        });
    }
}
maliming commented 1 week ago

hi