Idam.EntityFrameworkCore.Timestamps
10.0.0
dotnet add package Idam.EntityFrameworkCore.Timestamps --version 10.0.0
NuGet\Install-Package Idam.EntityFrameworkCore.Timestamps -Version 10.0.0
<PackageReference Include="Idam.EntityFrameworkCore.Timestamps" Version="10.0.0" />
<PackageVersion Include="Idam.EntityFrameworkCore.Timestamps" Version="10.0.0" />
<PackageReference Include="Idam.EntityFrameworkCore.Timestamps" />
paket add Idam.EntityFrameworkCore.Timestamps --version 10.0.0
#r "nuget: Idam.EntityFrameworkCore.Timestamps, 10.0.0"
#:package Idam.EntityFrameworkCore.Timestamps@10.0.0
#addin nuget:?package=Idam.EntityFrameworkCore.Timestamps&version=10.0.0
#tool nuget:?package=Idam.EntityFrameworkCore.Timestamps&version=10.0.0
Idam.EntityFrameworkCore.Timestamps
A .NET library for entity timestamps and softdelete. Easily manage CreatedAt, UpdatedAt, and DeletedAt fields with support for DateTime, UTC DateTime, and Unix time (milliseconds).
⭐ Support
If you find this library helpful, please consider giving it a star! Your support helps make it better.
🚀 Features
- Automatic handling of entity timestamps (CreatedAt, UpdatedAt, DeletedAt).
- Built-in soft delete functionality with global query filters.
- Support for multiple timestamp formats:
- Local
DateTime UTC DateTime.Unix Time (milliseconds)(learn more) (docs).
- Local
- Seamless integration with existing EF Core.
- Customizable field names with
[Column]attribute. - Flexible interfaces for individual timestamp requirements.
📦 Installation
.NET CLI
dotnet add package Idam.EntityFrameworkCore.Timestamps
🔧 Basic Setup
1. Configure DbContext
Call AddTimestamps() in your DbContext before saving changes.
...
using Idam.EntityFrameworkCore.Timestamps.Extensions;
public class MyDbContext : DbContext
{
public override int SaveChanges(bool acceptAllChangesOnSuccess)
{
ChangeTracker.AddTimestamps();
return base.SaveChanges(acceptAllChangesOnSuccess);
}
public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)
{
ChangeTracker.AddTimestamps();
return base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);
}
}
2. Define Your Entity
Implement the appropriate timestamps interface (ITimeStamps or ITimeStampsUtc or ITimeStampsUnix).
using Idam.EntityFrameworkCore.Timestamps.Interfaces;
/// Local DateTime
public class Product : ITimeStamps
{
...
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
/// UTC DateTime
public class Product : ITimeStampsUtc
{
...
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
/// Unix Time
public class Product : ITimeStampsUnix
{
...
public long CreatedAt { get; set; }
public long UpdatedAt { get; set; }
}
🗑️ Soft Delete
Setup
Call
AddSoftDeleteFilter()in yourDbContext.using Idam.EntityFrameworkCore.Timestamps.Extensions; public class MyDbContext : DbContext { protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.AddSoftDeleteFilter(); base.OnModelCreating(modelBuilder); } }Implement the appropriate soft delete interface (
ISoftDeleteorISoftDeleteUtcorISoftDeleteUnix).using Idam.EntityFrameworkCore.Timestamps.Interfaces; /// Local DateTime public class Product : ISoftDelete { ... public DateTime? DeletedAt { get; set; } } /// UTC DateTime public class Product : ISoftDeleteUtc { ... public DateTime? DeletedAt { get; set; } } /// Unix Time public class Product : ISoftDeleteUnix { ... public long? DeletedAt { get; set; } }
Operations
// Restore a soft-deleted item
_context.Products.Restore(product);
await context.SaveChangesAsync();
// Permanently delete an item
_context.Products.ForceRemove(product);
await context.SaveChangesAsync();
// Check if item is deleted
bool isDeleted = product.Trashed();
// Query including soft-deleted items
var deletedProducts = await _context.Products
.IgnoreQueryFilters()
.Where(x => x.DeletedAt != null)
.ToListAsync();
🎨 Customization
Custom Field Names
public class Product : ITimeStamps, ISoftDelete
{
[Column("AddedAt")]
public DateTime CreatedAt { get; set; }
[Column("ModifiedAt")]
public DateTime UpdatedAt { get; set; }
[Column("RemovedAt")]
public DateTime? DeletedAt { get; set; }
}
Individual Interfaces
public class Product : ICreatedAt { }
public class Product : ICreatedAtUtc { }
public class Product : ICreatedAtUnix { }
public class Product : IUpdatedAt { }
public class Product : IUpdatedAtUtc { }
public class Product : IUpdatedAtUnix { }
public class Product : ISoftDelete { }
public class Product : ISoftDeleteUtc { }
public class Product : ISoftDeleteUnix { }
🔄 Migration Guide
🤝 How to Contribute
We welcome contributions from the community! Here's how you can help make this project better:
Getting Started
- Fork the Repository: Click the "Fork" button at the top right of this repository.
- Clone Your Fork:
git clone https://github.com/your-username/Idam.EntityFrameworkCore.Timestamps.git cd Idam.EntityFrameworkCore.Timestamps - Create a Branch: Create a feature branch for your changes:
git checkout -b feature/your-feature-name
Making Changes
- Make Your Changes: Implement your feature or bug fix.
- Write Tests: Add or update tests to cover your changes.
- Follow Code Style: Ensure your code follows the project's existing code style and conventions.
- Commit Your Changes: Write clear, concise commit messages:
git commit -m "Add: brief description of your changes"
Submitting Your Contribution
- Push to Your Fork:
git push origin feature/your-feature-name - Open a Pull Request:
- Go to the original repository and click "New Pull Request"
- Select your branch and provide a clear description of your changes
- Reference any related issues using
#issue-number
Guidelines
- Code Quality: Ensure your code is clean and well-documented
- Testing: All tests must pass before submission
- Documentation: Update README.md or other docs if your changes introduce new features
- Issues: Check existing issues before starting work to avoid duplicates
- Communication: Be respectful and constructive in discussions
Reporting Issues
Found a bug or have a feature request? Please open an issue with:
- A clear title and description
- Steps to reproduce (for bugs)
- Expected vs. actual behavior
- Your environment details (.NET version, EF Core version, etc.)
Questions?
If you have any questions, feel free to open a discussion or reach out to the maintainers.
Thank you for your contributions! 🎉
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0 | 121 | 5/27/2026 |
Initial release with CreatedAt, UpdatedAt, and DeletedAt support.