FoundationKit 2.0.0

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

FoundationKit

icon

The fundamental kit of your application, which offers key components such as repositories, validations, base models, and configurations.

This library is separated in 4 components or nuggets:

  • FoundationKit - Contains all implementations from the library.
  • FoundationKit.EntityFrameworkCore - Contains the base DbContext and base models, configurations and access configuration for database.
  • FoundationKit.Repository - Contains the base repositories.
  • FoundationKit.Extensions - Contains the extensions for the library.

Configuration in program.cs:

//this configuration is necessary if you want use IMapRepository with IdentityDbContext
builder.Services.AddFoundationKitIdentity<User, ApplicationIdentityDbContext>(Assembly.GetExecutingAssembly());

//this configuration is necessary if you want use IMapRepository without IdentityDbContext
builder.Services.AddFoundationKit(Assembly.GetExecutingAssembly());

Release to NuGet

[Roadmap]

Only mark items are completed

  • Repository Pattern
  • Repository Pattern with Automapper ✅
  • Filter repository
  • Firebase Repository
  • AMQP RABBIT Integration
  • Services
    • NationalityService
    • StateService
    • CountryService
  • Validation
    • DPI
    • DNI
    • CreditCard
    • cvv validation
    • Date validation
    • Get credit card type
  • Configuration
  • Services
    • Mail Service
    • SecurityKey Service
  • Helpers
    • Notification Helper (MVC)
    • Export Excel
    • RSA Encryption / Decryption,
    • Format amounts
    • MD5 HASH
  • Extensions
    • Minimals api extensions
    • ICollection extensions
    • Enum extensions ✅
  • Others
    • Cookie based auth
  • Documentation ✅

Documentation

this documentation represent the main features of the library separated by sections.

Repository Pattern

Is a common pattern used in the development of applications, which allows us to abstract the data access layer, in this way we can change the data source without affecting the rest of the application.

how to use it?

  • Create a interface and Class as service and use the inheritance of the base repository, passing a model as a generic parameter when the model is a class that inherits from the base model. BaseModel

//database context inheritance
public class ApplicationDbContext : FoundationKitDbContext
{
    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
    {
    }
    public DbSet<Person> Persons { get; set; }
}

//using base model
public class Person : BaseModel
{
    public string? Name { get; set; }

    [NotMapped]
    public override string? CreatedBy { get; set; }
}

// inheritance base repository
public interface IPersonService
: IBaseRepository<Person>
{
}

// inheritance base repository and implementation of base repository
public class PersonService : BaseRepository<ApplicationDbContext, Person>, IPersonService
{
    public PersonService(ApplicationDbContext context) : base(context)
    {
    }
}

//usage in a minimal api endpoint
app.MapPost("/api/person", async ([FromServices] IPersonService service,
    Person person,
    CancellationToken cancellationToken) =>
    {
        return await service.Create(person, cancellationToken);
    })
    .WithName("add");

Configuration

Base Model

is a base class named BaseModel that allows us to have a common structure in our models, it has the following properties:

  • Id - is a unique identifier for the model.
  • CreatedAt - is the date of creation of the model.
  • UpdateAt - is the date of the last update of the model.
  • CreatedAtStr - is the date of creation of the model in string format. (dd/MM/yyyy hh:mm:ss)
  • UpdateAtStr - is the date of the last update of the model in string format. (dd/MM/yyyy hh:mm:ss)
  • IsDeleted - is a flag that indicates if the model is deleted.
  • CreatedBy - is the user who created the model.
  • UpdatedBy - is the user who updated the model.

Paginate

is a class named Paginate that allows us to paginate a list of models; please see the paginate class.

Core API Controllers

Contains the CoreApiController class which inherits from ControllerBase and contains the next characteristics:

  • GetByIdAsync - is a method that allows us to obtain a model by its id.
  • GetAllPaginatedAsync - is a method that allows us to obtain all the models paginated or not please see Paginate.
  • AddAsync - is a method that allows us to create a model.
  • UpdateAsync - is a method that allows us to update a model.
  • DeleteAsync - is a method that allows up to update a model with the IsDeleted flag in true.

Example in FoundationKit.API.Example/Controllers/PersonController.cs

Base DbContext

Contains the FoundationKitDbContext class which inherits from DbContext and contains the next characteristics:

  • SaveChanges: Override the SaveChanges method to set the CreatedAt and UpdateAt properties of the models.
  • SaveChangesAsync: Override the SaveChangesAsync method to set the CreatedAt and UpdateAt properties of the models.

Extensions

GetDisplayName

This extension allows us to obtain the name of the enum value based in the [Display] attribute if it exists, otherwise it returns the name of the enum based in your code.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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
4.0.5 186 11/27/2025
4.0.4 197 1/23/2025
4.0.3 155 1/23/2025
4.0.2 206 1/7/2025
4.0.1 157 1/7/2025
4.0.0 1,636 5/10/2024
3.0.0 512 10/6/2023
2.2.4 361 9/28/2023
2.1.4 223 9/21/2023
2.1.3 243 8/30/2023
2.1.2 216 8/30/2023
2.1.0 239 8/23/2023
2.0.7 226 8/23/2023
2.0.6 230 8/18/2023
2.0.5 256 8/9/2023
2.0.4 253 8/9/2023
2.0.3 258 8/8/2023
2.0.2 261 8/7/2023
2.0.1 240 8/1/2023
2.0.0 240 7/29/2023
1.1.2 287 7/11/2023
1.1.1 266 7/11/2023
1.0.1 243 7/10/2023
0.0.1 241 7/7/2023