Gtlabs.Persistence 1.4.1

dotnet add package Gtlabs.Persistence --version 1.4.1
                    
NuGet\Install-Package Gtlabs.Persistence -Version 1.4.1
                    
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="Gtlabs.Persistence" Version="1.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Gtlabs.Persistence" Version="1.4.1" />
                    
Directory.Packages.props
<PackageReference Include="Gtlabs.Persistence" />
                    
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 Gtlabs.Persistence --version 1.4.1
                    
#r "nuget: Gtlabs.Persistence, 1.4.1"
                    
#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 Gtlabs.Persistence@1.4.1
                    
#: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=Gtlabs.Persistence&version=1.4.1
                    
Install as a Cake Addin
#tool nuget:?package=Gtlabs.Persistence&version=1.4.1
                    
Install as a Cake Tool

Gtlabs.Persistence

Persistence library for .NET applications that provides integrations and conventions on top of Entity Framework Core using Repository and Unit of Work patterns. Includes base entities (auditing, soft-delete), a custom DbContext, migration extensions and a service to apply migrations at startup.

Structure (summary)

  • CustomDbContext/: custom DbContext implementation used by the application.
  • Entities/: base entities (Entity, AuditedEntity, SoftDeleteEntity).
  • Extensions/: helpers for database configuration and migrations.
  • Repository/: IRepository, Repository and UnitOfWork.
  • Services/: service to apply migrations automatically.

Use case: CustomDbContext

Use GtLabsDbContext to centralize model configuration, conventions and auditing/interceptors before using repositories or EF directly.

Example:

// register in DI
services.AddDbContext<GtLabsDbContext>(opts =>
    opts.UseSqlServer(configuration.GetConnectionString("Default")));

// inject and use
public class MyAppService
{
    private readonly GtLabsDbContext _db;
    public MyAppService(GtLabsDbContext db) => _db = db;

    public void Add<T>(T entity) where T : class
    {
        _db.Set<T>().Add(entity);
        _db.SaveChanges();
    }
}

Use case: Repository

Use the Repository pattern to isolate data access logic from the application layer, simplifying tests and centralizing query rules.

Example:

public class MyService
{
    private readonly IRepository<MyEntity> _repo;
    private readonly IUnitOfWork _uow;

    public MyService(IRepository<MyEntity> repo, IUnitOfWork uow)
    {
        _repo = repo;
        _uow = uow;
    }

    public IEnumerable<MyEntity> ListActive()
    {
        return _repo.Where(e => !e.IsDeleted).ToList();
    }

    public void Create(MyEntity e)
    {
        _repo.Add(e);
        _uow.SaveChanges();
    }
}

Installation

Add the project reference or publish as a NuGet package and reference it in your project.

License

See the LICENSE file in the root repository for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.4.1 80 6/9/2026
1.4.0 111 6/7/2026