https://github.com/gabisonia/kvali
Audit trail library for .net
https://github.com/gabisonia/kvali
audit-trail
Last synced: about 1 month ago
JSON representation
Audit trail library for .net
- Host: GitHub
- URL: https://github.com/gabisonia/kvali
- Owner: gabisonia
- Created: 2024-12-03T17:26:25.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-12-05T17:08:08.000Z (6 months ago)
- Last Synced: 2025-03-29T01:51:42.908Z (2 months ago)
- Topics: audit-trail
- Language: C#
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kvali - კვალი
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.
## Features
- 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.## Usage
### 1. Inherit `AuditableDbContext`
To enable auditing in your DbContext, inherit from `AuditableDbContext` instead of `DbContext`. Here's an example:
```csharp
public class TestDbContext : AuditableDbContext
{
public TestDbContext(DbContextOptions options)
: base(options) { }public DbSet Products { get; set; }
public DbSet Users { get; set; }
}
```### 2. Annotate Your Models for Auditing
```csharp
[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```csharp
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; }
}
```### 3. Action-Specific Auditing
```csharp
// Only audits on create actions.
[AuditAction(AuditActionType.Create)]
public class User : IAuditable
{
public int Id { get; set; }
public string Name { get; set; }
}
```### 4. Add and Apply Migrations
Before using **Kvali**, ensure you generate and apply the necessary migrations to your database. Follow these steps:
1. **Generate the Migration**:
Run the following command in the Package Manager Console or terminal:
```bash
dotnet ef migrations add InitialAuditMigration
```
2. **Apply the Migration:**:
Run the following command to update the database with the migration:
```bash
dotnet ef database update
```
## License
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!