- ABP Framework version: v4.2.2
- UI type: Angular
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): yes
- Exception message and stack trace:
- Steps to reproduce the issue:"
Hi Team, we are facing performance issue when Audit table size is large like 1 GB. Can we move All Audit related tables to seperate SQL DB. If yes, how.
9 Answer(s)
-
0
You can use AbpAuditLogging connection string for separate audit logging in appsettings like:
"ConnectionStrings": { "Default": "Server=localhost;Database=ApplicationDb;Trusted_Connection=True;", "AbpAuditLogging": "Server=localhost;Database=AuditLoggingDb;Trusted_Connection=True;" }Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Thanks gterdem. I am using Window10 and VS 2022. After making connection string changes in appsettings in host, identity and DBMigrator project, i run the DBMigrator project but Audit tables not created in new audit db.
What step i should take to create Audit feature realted tables in new DB.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
-
0
Could not understand where exactly i have to make changes. As it seems i have seperate set of files.
In entity framework core i have 4 files: EzpandCCDbContext EzpandCCDbContextModelCreatingExtensions EzpandCCEfCoreEntityExtensionMappings EzpandCCEntityFrameworkCoreModule
in sample 7 files provided BookStoreDbContext.cs BookStoreDbContextFactory.cs BookStoreEfCoreEntityExtensionMappings.cs BookStoreEntityFrameworkCoreModule.cs BookStoreSecondDbContext.cs BookStoreSecondDbContextFactory.cs EntityFrameworkCoreBookStoreDbSchemaMigrator.cs
*DbContextFactory, EntityFrameworkCoreBookStoreDbSchemaMigrator is surely missing. Do i have to create them also. If yes can you confrim me all Audit related tables exist so that i can keep them in secodDbContext and will emove from *DBContext. Please remember i am using 4.2.2
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hello, I have explained how to do this step by step below. You can do it this way too. If you have any questions, please don't hesitate to ask.
- Create
EzpandCCSecondDbContext.csinEzpandCC.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/
- Create
EzpandCCSecondDbContextFactory.csinEzpandCC.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/
- Remove below line from
EzpandCCMigrationsDbContextinEzpandCC.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/
builder.ConfigureAuditLogging();- Add below lines to
MigrateAsyncmethod inEntityFrameworkCoreEzpandCCDbSchemaMigratorclass inEzpandCC.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/
await _serviceProvider .GetRequiredService<EzpandCCSecondDbContext>() .Database .MigrateAsync();- Add below line to
ConfigureServicesmetod inEzpandCCEntityFrameworkCoreDbMigrationsModuleclass inEzpandCC.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/
context.Services.AddAbpDbContext<EzpandCCSecondDbContext>();- Add the following connection string under
Defaultfor allappsettings.json.
"AbpAuditLogging": "Server=(LocalDb)\\MSSQLLocalDB;Database=EzpandCC;Trusted_Connection=True"- Run below commands in
EzpandCC.EntityFrameworkCore.DbMigrations/
dotnet ef migrations add "Initial" --context EzpandCCMigrationsDbContextdotnet ef migrations add "Initial" --context EzpandCCSecondDbContext- Finally, run the
EzpandCC.DbMigratorproject.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) - Create
-
0
Run below commands in EzpandCC.EntityFrameworkCore.DbMigrations/
dotnet ef migrations add "Initial" --context EzpandCCMigrationsDbContextdotnet ef migrations add "Initial" --context EzpandCCSecondDbContext
These two commands need to be run sequentially, not together.
Additional Information
If you changed the name of the second DbContext you created, if
EzpandCCSecondDbContextis different from this name, it should change accordingly in the command.For example: My second DB context name is
MyNewDbContextand so I have to write the following code.dotnet ef migrations add "Initial" --context MyNewDbContextMarkdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Closing the question. Feel free to re-open if the problem is not resolved.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)


