Kvali (Georgian: კვალი) is a lightweight and flexible .NET Core library for implementing audit trails in your applications. It helps you track changes, log actions, and maintain a detailed history of operations for auditing and debugging purposes.
- Seamless integration with .NET Core applications.
- Tracks and logs create, update, and delete operations.
- Stores comprehensive audit data, including datetime, user actions, and object changes.
- Configurable and extensible for custom audit requirements.
- Lightweight and performance-oriented.
To enable auditing in your DbContext, inherit from AuditableDbContext
instead of DbContext
. Here's an example:
public class TestDbContext : AuditableDbContext
{
public TestDbContext(DbContextOptions<TestDbContext> options)
: base(options) { }
public DbSet<Entities> Products { get; set; }
public DbSet<User> Users { get; set; }
}
[Auditable]
public class Entities
{
public int Id { get; set; }
public string Name { get; set; }
// This property will be ignored during auditing.
[IgnoreAudit]
public decimal Price { get; set; }
}
Or
public class Entities : IAuditable
{
public int Id { get; set; }
public string Name { get; set; }
// This property will be ignored during auditing.
[IgnoreAudit]
public decimal Price { get; set; }
}
// Only audits on create actions.
[AuditAction(AuditActionType.Create)]
public class User : IAuditable
{
public int Id { get; set; }
public string Name { get; set; }
}
Before using Kvali, ensure you generate and apply the necessary migrations to your database. Follow these steps:
-
Generate the Migration:
Run the following command in the Package Manager Console or terminal:
dotnet ef migrations add InitialAuditMigration
-
Apply the Migration::
Run the following command to update the database with the migration:
dotnet ef database update
Kvali is fully free to use, modify, and distribute for any purpose, personal or commercial.
No attribution is required, but contributions and feedback are always welcome!