EFTimestamps 1.0.0

dotnet add package EFTimestamps --version 1.0.0
NuGet\Install-Package EFTimestamps -Version 1.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="EFTimestamps" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EFTimestamps --version 1.0.0
#r "nuget: EFTimestamps, 1.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.
// Install EFTimestamps as a Cake Addin
#addin nuget:?package=EFTimestamps&version=1.0.0

// Install EFTimestamps as a Cake Tool
#tool nuget:?package=EFTimestamps&version=1.0.0


A library for handling timestamps & soft deletes in Entity Framework.


  • Introduction
  • Getting started
  • Usage
  • Methods
  • Notes


EFTimestamps is a library that control the dates your models have been created, updated, or (soft) deleted, automatically handling all CRUD operations in the DB context. When models are soft deleted, they are not actually deleted from the database, instead a DeletedAt column is set to the date the model has been deleted. If a model's DeletedAt value is not null, and is set to a specific date, it means it has been deleted.

Getting started

EFTimestamps library is available in nuget.org. To install it, run the following command in the Package Manager Console: Install-Package EFTimestamps

Next, let your DB context inheirt from TimestampsDbContext, as follows:

public class ApplicationDbContext : TimestampsDbContext


For a model to have the columns CreatedAt and UpdatedAt, let it implement the ITimestamps interface and all its members, as follows:

public class Person : ITimestamps
  public int Id { get; set; }
  public string Name { get; set; }
  // ITimestamps implementation
  public DateTime CreatedAt { get; set; }
  public DateTime UpdatedAt { get; set; }

Along with timestamps, a model can be soft-deletable by implementing the ISoftDeletable interface as follows:

public class Person : ITimestamps, ISoftDeletable
  public int Id { get; set; }
  public string Name { get; set; }
  // ITimestamps implementation
  public DateTime CreatedAt { get; set; }
  public DateTime UpdatedAt { get; set; }
  // ISoftDeletable implementation
  public DateTime? DeletedAt { get; set; }

That's it! Your model can now have timestamps via the CreatedAt and UpdatedAt columns, as well as be soft deleted via the DeletedAt columns.


You can use the following helper methods to extend your use of soft deletes:

  • Soft deleting a model:
var person = DbContext.Persons.First();
  • Restoring a model:
  • Checking if a model is deleted:
  • If you don't want a model to be soft-deleted, and want it permanently removed, you can force-remove it:


TimestampsDbContext is currently incompatible with IdentityDbContext used in ASP.NET MVC projects. It will however be available hopefully in the next versions of the library.

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 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
1.0.0 1,234 11/29/2017