DK.GenericLibrary 2.0.0

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

Package primarily made for ASP.NET Applications, but can work with any project utilizing ServiceProviders.

!Important The solutions UpdateItem(s) methods can dynamically register changes of 1 nested collection, anything past that will need either a custom extension or to simply pass it directly into the parameter. As the collection items are part of the DbSet it will be able to update correctly.

This package provides a fully generic repository to fulfill the common CRUD actions with Entity Framework, without writing the same 8 lines 15 times per repository.

The gist of the package is, that by registering the Interface and/or class implementation, as well as the IDbContextFactory with a given context, each and every method in this package will create and dispose a new context every time.

All the (Async at least) methods has examples of how to use it in the documentation/mouseover.

How to use: ASP.Net core

Register services

Only register the one you need, newly added Service extension to quickly register the services.

image

It's important that the Context is registered as a IDbContextFactory as this is used to handle instantiation and disposal of context instances.

Inject repository into a service or wherever needed

image

Define methods and use the generic methods to retrieve what you need

Example:

image

Currently tested all methods and registrations of Async and regular repositories. image

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
2.0.0 92 6/1/2026
1.3.0 298 9/22/2025
1.2.0 172 8/23/2025
1.1.4 287 4/17/2025
1.1.3 263 4/17/2025
1.1.2 269 4/17/2025
1.1.1 184 3/29/2025

Updated for EF Core 10.0.2 (newest compatible with PostgreSQL)