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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Idam.EntityFrameworkCore.Timestamps" Version="10.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Idam.EntityFrameworkCore.Timestamps" Version="10.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Idam.EntityFrameworkCore.Timestamps" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Idam.EntityFrameworkCore.Timestamps --version 10.0.0
                    
#r "nuget: Idam.EntityFrameworkCore.Timestamps, 10.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Idam.EntityFrameworkCore.Timestamps@10.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Idam.EntityFrameworkCore.Timestamps&version=10.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Idam.EntityFrameworkCore.Timestamps&version=10.0.0
                    
Install as a Cake Tool

Idam.EntityFrameworkCore.Timestamps

NuGet Build Status

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).
  • 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

  1. Call AddSoftDeleteFilter() in your DbContext.

    using Idam.EntityFrameworkCore.Timestamps.Extensions;
    
    public class MyDbContext : DbContext
    {
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.AddSoftDeleteFilter();
    
            base.OnModelCreating(modelBuilder);
        }
    }
    
  2. Implement the appropriate soft delete interface (ISoftDelete or ISoftDeleteUtc or ISoftDeleteUnix).

    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

  1. Fork the Repository: Click the "Fork" button at the top right of this repository.
  2. Clone Your Fork:
    git clone https://github.com/your-username/Idam.EntityFrameworkCore.Timestamps.git
    cd Idam.EntityFrameworkCore.Timestamps
    
  3. Create a Branch: Create a feature branch for your changes:
    git checkout -b feature/your-feature-name
    

Making Changes

  1. Make Your Changes: Implement your feature or bug fix.
  2. Write Tests: Add or update tests to cover your changes.
  3. Follow Code Style: Ensure your code follows the project's existing code style and conventions.
  4. Commit Your Changes: Write clear, concise commit messages:
    git commit -m "Add: brief description of your changes"
    

Submitting Your Contribution

  1. Push to Your Fork:
    git push origin feature/your-feature-name
    
  2. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.