- ABP Framework version: v7.1.1
- UI Type:
- Database System: SQL Server
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace:
* An exception was thrown while activating Volo.Abp.AuditLogging.EntityFrameworkCore.AbpAuditLoggingDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions`1[[Volo.Abp.AuditLogging.EntityFrameworkCore.AbpAuditLoggingDbContext, Volo.Abp.AuditLogging.EntityFrameworkCore, Version=7.1.1.0, Culture=neutral, PublicKeyToken=null]].
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Abp.AuditLogging.EntityFrameworkCore.AbpAuditLoggingDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions`1[[Volo.Abp.AuditLogging.EntityFrameworkCore.AbpAuditLoggingDbContext, Volo.Abp.AuditLogging.EntityFrameworkCore, Version=7.1.1.0, Culture=neutral, PublicKeyToken=null]].
---> Volo.Abp.AbpException: No configuration found for Microsoft.EntityFrameworkCore.DbContext, Microsoft.EntityFrameworkCore, Version=7.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60! Use services.Configure<AbpDbContextOptions>(...) to configure it.
at Volo.Abp.EntityFrameworkCore.DependencyInjection.DbContextOptionsFactory.Configure[TDbContext](AbpDbContextOptions options, AbpDbContextConfigurationContext`1 context)
at Volo.Abp.EntityFrameworkCore.DependencyInjection.DbContextOptionsFactory.Create[TDbContext](IServiceProvider serviceProvider)
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Activators.Delegate.DelegateActivator.<ConfigurePipeline>b__2_0(ResolveRequestContext ctxt, Action`1 next)
at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next) at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
--- End of inner exception stack trace ---
at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider`1.CreateDbContextAsync(IUnitOfWork unitOfWork)
at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider`1.CreateDbContextAsync(IUnitOfWork unitOfWork, String connectionStringName, String connectionString)
at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider`1.GetDbContextAsync()
at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository`2.InsertAsync(TEntity entity, Boolean autoSave, 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.AuditLogging.AuditingStore.SaveLogAsync(AuditLogInfo auditInfo)
at Volo.Abp.AuditLogging.AuditingStore.SaveAsync(AuditLogInfo auditInfo)
- Steps to reproduce the issue:
- Dear Supports,
I am trying to add abp auditlogging service to the microservice template project. I have manually created the migrations to add the following tables: [AbpAuditLogs] [AbpAuditLogActions] [AbpEntityChanges] [AbpEntityPropertyChanges]
then, In application layer, added
<PackageReference Include="Volo.Abp.AuditLogging.Application" Version="7.1.1" />
and xxxApplicationModule.cs
Configure<AbpAuditingOptions>(options =>
{
options.EntityHistorySelectors.AddAllEntities();
});
In domain.shared layer, added
<PackageReference Include="Volo.Abp.AuditLogging.Domain.Shared" Version="7.1.1" />
xxxDomainSharedModule.cs added
[DependsOn(
....
typeof(AbpAuditLoggingDomainSharedModule)
)]
In EntityFrameworkCore layer, added
<PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="7.1.1" />
DbContext.cs added
builder.ConfigureAuditLogging();
In HttpApi, HttpApi.Client and HttpApi.Host layer, the reference is also added.
I would like to know how to configure the Dbcontext as it shows No configuration found?
11 Answer(s)
-
0
hi
Do you depend on the
AbpAuditLoggingEntityFrameworkCoreModule
on theEntityFrameworkCore
layer? -
0
hi
Do you depend on the
AbpAuditLoggingEntityFrameworkCoreModule
on theEntityFrameworkCore
layer?Yes.
[DependsOn( typeof(AbpEntityFrameworkCoreSqlServerModule), typeof(AbpEntityFrameworkCoreModule), typeof(AbpAuditLoggingEntityFrameworkCoreModule) )]
In ConfigureServices
Configure< AbpDbContextOptions>(options => { options.Configure< MyServiceDbContext>(c => { c.UseSqlServer(b => { b.MigrationsHistoryTable("__MyService_Migrations", MyServiceDbProperties.DbSchema); }); }); });
-
0
hi
options.UseSqlServer(); // add this line.
See https://docs.abp.io/en/abp/latest/Entity-Framework-Core#abpdbcontextoptions
Configure<AbpDbContextOptions>(options => { options.Configure<MyServiceDbContext>(c => { c.UseSqlServer(b => { b.MigrationsHistoryTable("__MyService_Migrations", MyServiceDbProperties.DbSchema); }); }); options.UseSqlServer(); // add this line. });
or
Configure<AbpDbContextOptions>(options => { options.Configure<MyServiceDbContext>(c => { c.UseSqlServer(b => { b.MigrationsHistoryTable("__MyService_Migrations", MyServiceDbProperties.DbSchema); }); }); options.Configure<AbpAuditLoggingDbContext>(c => { c.UseSqlServer... }); });
-
0
options.UseSqlServer();
Thank you so much. It resolved the error. However, when doing CRUD of the app service function, there is no record inserted to the AuditLog related tables. What else do I need to configure?
-
0
hi
UseAuditing() middleware should be added to the ASP.NET Core request pipeline in order to create and save the audit logs. If you've created your applications using the startup templates, it is already added.
https://docs.abp.io/en/abp/latest/Audit-Logging#useauditing
-
0
UseAuditing()
hi, yes I have added this configuration and I found the log is actually inserted into the table with schema dbo dbo.[AbpAuditLogs] dbo.[AbpAuditLogActions] dbo.[AbpEntityChanges] dbo.[AbpEntityPropertyChanges]
Can I customize the schema of these tables? who to override AbpCommonDbProperties?
-
0
hi
You can change this static variable in
Program.cs
of all projectsAbpAuditLoggingDbProperties.DbSchema = "xxx"
-
0
hi
You can change this static variable in
Program.cs
of all projectsAbpAuditLoggingDbProperties.DbSchema = "xxx"
As I am using the microservice templeate, only HttpApi.Host contains the program.cs, add the static variable in here in enough?
-
0
hi
May not be enough, and other services may get a table not found error. You'd better change this in all projects that reference or indirectly reference to
AbpAuditLoggingEntityFrameworkCoreModule
-
0
hi
May not be enough, and other services may get a table not found error. You'd better change this in all projects that reference or indirectly reference to
AbpAuditLoggingEntityFrameworkCoreModule
hi, could you provide some examples of the implementation? I am not sure where and how to add this
-
0
hi
You can ignore this for now. Try to test if the
AuditLogging
works.