Skip to content

Extension for Entity Framework (EF) Core 8 (or higher) that adds support for SQLite row versioning ([Timestamp] attribute).

License

Notifications You must be signed in to change notification settings

dorssel/dotnet-ef-sqlite-timestamp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotnet-ef-sqlite-timestamp

Build CodeQL MegaLinter Codecov REUSE status NuGet

Extension for Entity Framework (EF) Core 8.0 (or higher) that adds support for SQLite row versioning ([Timestamp] attribute).

The implementation is for AnyCPU, and works on all platforms.

Usage

Add a package reference to your project for Dorssel.EntityFrameworkCore.Sqlite.Timestamp, next to an explicit reference to the required version of SQLite.

For EF Core 8:

   <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.*" />
+  <PackageReference Include="Dorssel.EntityFrameworkCore.Sqlite.Timestamp" Version="*" />

For EF Core 9:

   <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.*" />
+  <PackageReference Include="Dorssel.EntityFrameworkCore.Sqlite.Timestamp" Version="*" />

Note

It is not recommended to solely rely on the transitive dependency on Microsoft.EntityFrameworkCore.Sqlite, as that would use the version at the time Dorssel.EntityFrameworkCore.Sqlite.Timestamp was built instead of the latest one. Therefore, always add an explicit package reference for Microsoft.EntityFrameworkCore.Sqlite in your project as well.

In your DbContext derived class modify the following:

+  using Dorssel.EntityFrameworkCore;

   protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
   {
     optionsBuilder
       .UseSqlite($"Data Source={DbPath}")
+      .UseSqliteTimestamp();
   }

This is all you need to support row versioning with SQLite, including support for migrations.

See Native database-generated concurrency tokens; except now you can ignore the part that says it isn't supported with SQLite!

Example

See the Example project for a demonstration using .NET 9 & EF Core 9.

NuGet package

The released NuGet package and the .NET assemblies contained therein have the following properties:

About

Extension for Entity Framework (EF) Core 8 (or higher) that adds support for SQLite row versioning ([Timestamp] attribute).

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Contributors 4

  •  
  •  
  •  
  •  

Languages