QuickAPI.Database 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package QuickAPI.Database --version 1.0.0
                    
NuGet\Install-Package QuickAPI.Database -Version 1.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="QuickAPI.Database" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="QuickAPI.Database" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="QuickAPI.Database" />
                    
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 QuickAPI.Database --version 1.0.0
                    
#r "nuget: QuickAPI.Database, 1.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.
#addin nuget:?package=QuickAPI.Database&version=1.0.0
                    
Install QuickAPI.Database as a Cake Addin
#tool nuget:?package=QuickAPI.Database&version=1.0.0
                    
Install QuickAPI.Database as a Cake Tool

QuickAPI.Database

Overview

QuickAPI.Database is a foundational library for database components in QuickAPI. It provides a set of base models, a core DbContext implementation, an interface for tenant-based multi-tenancy support, and custom data annotations for EF Core models.

This package is designed to be used in backend projects that require database operations with Entity Framework Core.

Features

  • Base Models: Provides a BaseModel class with common fields such as Id, CreatedAt, ModifiedAt, and IsDeleted.
  • Custom EF Core Extensions: Includes helpers for applying custom attributes and constraints on entity properties.
  • Tenant Support: Implements ITenantModel to enforce tenant-based filtering.
  • Base DbContext: A BaseContext class that automatically applies query filters, tracks modifications, and handles tenant-aware queries.
  • Custom Data Annotations: Attributes for defining SQL default values, computed columns, primary keys, and constraint indexes.

Installation

To install this package via NuGet:

dotnet add package QuickAPI.Database

This package requires EF Core. Ensure you have installed Microsoft.EntityFrameworkCore in your project.

Usage

BaseModel

All entity models should inherit from BaseModel to get common fields and automatic tracking.

using QuickAPI.Database.DataModels;

public class Product : BaseModel
{
    public decimal Price { get; set; }
}

Tenant Support

To support multi-tenancy, a model should implement ITenantModel:

using QuickAPI.Database.DataModels;

public class Order : BaseModel, ITenantModel
{
    public Guid TenantId { get; set; }
    public decimal TotalAmount { get; set; }
}

BaseContext

The BaseContext class automatically applies:

  • Tenant-based filtering using _tenantProvider
  • Timestamps for created and modified fields
  • Cascade delete restrictions for safer operations
Example Usage:
using Microsoft.EntityFrameworkCore;
using QuickAPI.Database.Data;

public class AppDbContext : BaseContext
{
    public AppDbContext(DbContextOptions<AppDbContext> options, ITenantProvider tenantProvider)
        : base(options, tenantProvider)
    {
    }

    public DbSet<Product> Products { get; set; }
}

Applying Custom Data Annotations

Use built-in attributes for defining SQL constraints directly in your models.

Default Values
[SqlDefaultValue("getdate()")]
public DateTimeOffset CreatedAt { get; set; }
Computed Columns
[SqlComputed("Price * Quantity", stored: true)]
public decimal TotalCost { get; set; }
Primary Key Naming
[SqlPrimaryKey("PK_CustomKey", "Id")]
public class CustomEntity
{
    public int Id { get; set; }
}

Notes

  • This package is only for backend projects.
  • It is meant to be referenced in QuickAPI but can be used in any .NET project using EF Core.
  • Supports SQL Server, PostgreSQL, and other EF Core-supported databases.

License

This project is licensed under the Apache 2.0 License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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