{"id":21520628,"url":"https://github.com/mrnkr/eftimestamps","last_synced_at":"2026-05-17T20:04:48.278Z","repository":{"id":97408879,"uuid":"255474702","full_name":"mrnkr/EFTimestamps","owner":"mrnkr","description":"Put timestamps in your entities the easy way","archived":false,"fork":false,"pushed_at":"2023-04-25T20:26:18.000Z","size":43,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T04:43:36.115Z","etag":null,"topics":["dotnet-core","entity-framework-core","timestamps"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/EFTimestamps.Configuration/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrnkr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-14T00:49:11.000Z","updated_at":"2022-09-25T02:54:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a6aba01-28d9-4ce1-80ba-110843b61e22","html_url":"https://github.com/mrnkr/EFTimestamps","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrnkr%2FEFTimestamps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrnkr%2FEFTimestamps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrnkr%2FEFTimestamps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrnkr%2FEFTimestamps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrnkr","download_url":"https://codeload.github.com/mrnkr/EFTimestamps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244075637,"owners_count":20393979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet-core","entity-framework-core","timestamps"],"created_at":"2024-11-24T01:02:03.029Z","updated_at":"2026-05-17T20:04:43.241Z","avatar_url":"https://github.com/mrnkr.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EFTimestamps\n\n[![NuGet version][nuget-image]][nuget-url]\n[![Downloads][downloads-image]][nuget-url]\n[![Build Status](https://travis-ci.com/mrnkr/EFTimestamps.svg?branch=master)](https://travis-ci.com/mrnkr/EFTimestamps)\n[![codecov](https://codecov.io/gh/mrnkr/EFTimestamps/branch/master/graph/badge.svg)](https://codecov.io/gh/mrnkr/EFTimestamps)\n[![License][license]][nuget-url]\n\n[nuget-image]:https://img.shields.io/nuget/v/EFTimestamps.Annotations\n[nuget-url]:https://www.nuget.org/packages/EFTimestamps.Annotations\n[downloads-image]:https://img.shields.io/nuget/dt/EFTimestamps.Annotations\n[license]:https://img.shields.io/github/license/mrnkr/EFTimestamps\n\nPut timestamps in your entities the easy way\n\n## Motivation\n\nUsing timestamps is something I do in almost every app I make, if you're here probably you do too. Since I always follow the same approach to implement them I just ended up making this library in order not to have to rewrite this code ever again. Hopefully you'll be able to find some use for it too!\n\n## Quick start\n\nInstall both [`EFTimestamps.Annotations`](https://www.nuget.org/packages/EFTimestamps.Annotations) and [`EFTimestamps.Configuration`](https://www.nuget.org/packages/EFTimestamps.Configuration). It is divided in two libs so that you can have your entities in a separate `dll` that does not know about EFCore.\n\nAfter that, mark your timestamp properties with the data annotations.\n\n```cs\nusing EFTimestamps.Annotations;\n\npublic class TestEntity\n{\n    [CreatedAt]\n    public DateTime CreatedAt { get; set; }\n\n    [UpdatedAt]\n    public DateTime UpdatedAt { get; set; }\n}\n```\n\nThen, go to your DbContext and override the variant of `SaveChanges` or `SaveChangesAsync` that you use in your persistence layer.\n\nAdditionally, you can tell EFCore to create indexes for your timestamps by calling `modelBuilder.IndexTimestamps()` in `OnModelCreating`.\n\nHere is an example of a `DbContext` that does both these things.\n\n```cs\nusing EFTimestamps.Configuration;\nusing Microsoft.EntityFrameworkCore;\n\npublic class TestContext : DbContext\n{\n    protected override void OnModelCreating(ModelBuilder modelBuilder)\n    {\n        modelBuilder.IndexTimestamps();\n    }\n\n    public override int SaveChanges()\n    {\n        this.UpdateTimestamps();\n        return base.SaveChanges();\n    }\n\n    public override int SaveChanges(bool acceptAllChangesOnSuccess)\n    {\n        this.UpdateTimestamps();\n        return base.SaveChanges(acceptAllChangesOnSuccess);\n    }\n\n    public override Task\u003cint\u003e SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default)\n    {\n        this.UpdateTimestamps();\n        return base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken);\n    }\n\n    public override Task\u003cint\u003e SaveChangesAsync(CancellationToken cancellationToken = default)\n    {\n        this.UpdateTimestamps();\n        return base.SaveChangesAsync(cancellationToken);\n    }\n}\n```\n\n## Changelog\n\n* 1.0.0 - First release\n* 1.0.1 - Bug fix\n* 1.1.0 - Add indexing for timestamp properties\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrnkr%2Feftimestamps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrnkr%2Feftimestamps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrnkr%2Feftimestamps/lists"}