EFTimestamps 1.0.0

.NET Framework 4.5
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.
dotnet add package EFTimestamps --version 1.0.0
<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, C# scripting and .NET Interactive. 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 Versions
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
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 957 11/29/2017