Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Save & Retrive Audit and EntityCahnges on a sepearte database #10860


User avatar
0
amerWAM created

Dears,

Could you help me to configure a separate database for AuditingStore and EntityHistory. I can't find any full soultion worked for that. As database growing fast from those tables I see it will be better to move them into seperate database with its own connevtionstring for sqlserver

Regards,


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    In order to implement your own AuditingStore, you first need to create a custom implementation, something like this;

    public class MyAuditingStore : IAuditingStore, ITransientDependency { // custom implementation }

    Then, you need to replace the existing one with your implementation like this in the PreInitialize method of your Core module;

    Configuration.ReplaceService<IAuditingStore, MyAuditingStore>();
    

    You can implement a same approach for IEntityHistoryStore.

  • User Avatar
    0
    amerWAM created

    Hi,

    Thanks for your answer. I figured out how to save auditt data on mongoDb and it is done. Now I can't get data bask to be read on the UI I changed AuditLogAppService to get data from mongoDB client but it fires exception: "System.Reflection.TargetException: Non-static method requires a target." when GetAuditLogs method call var resultCount = await query.CountAsync();

    Please let me know what i did wrong in the below code.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @amerWAM

    I haven't queried data from MongoDB but I think your query is not executable in MongoDB. You can try to remove filter and sorting etc... and try to execute your query again.

  • User Avatar
    0
    amerWAM created

    Thank you very much, yeah its regarding mongo query.