Aiursoft.DbTools.Sqlite 9.0.11

dotnet add package Aiursoft.DbTools.Sqlite --version 9.0.11                
NuGet\Install-Package Aiursoft.DbTools.Sqlite -Version 9.0.11                
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="Aiursoft.DbTools.Sqlite" Version="9.0.11" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aiursoft.DbTools.Sqlite --version 9.0.11                
#r "nuget: Aiursoft.DbTools.Sqlite, 9.0.11"                
#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.
// Install Aiursoft.DbTools.Sqlite as a Cake Addin
#addin nuget:?package=Aiursoft.DbTools.Sqlite&version=9.0.11

// Install Aiursoft.DbTools.Sqlite as a Cake Tool
#tool nuget:?package=Aiursoft.DbTools.Sqlite&version=9.0.11                

DBTools

MIT licensed Pipeline stat Test Coverage NuGet version (Aiursoft.CSTools) ManHours

DbTools are Aiursoft's common database tools. It simplifies the process of registering DbContext and updating database. So your application can easily switch from different database types.

Installation

To install Aiursoft.DbTools to your project from nuget.org:

dotnet add package Aiursoft.DbTools

Project structure

---
title: Project dependency diagram
---

stateDiagram-v2
    Aiursoft.DbTools.InMemory --> Aiursoft.DbTools
    Aiursoft.DbTools.Sqlite --> Aiursoft.DbTools
    Aiursoft.DbTools.MySql --> Aiursoft.DbTools
    Aiursoft.DbTools.Switchable --> Aiursoft.DbTools
    Demo.Entities --> Aiursoft.DbTools
    Demo.Sqlite --> Aiursoft.DbTools.Sqlite
    Demo.Sqlite --> Demo.Entities
    Demo.MySql --> Aiursoft.DbTools.MySql
    Demo.MySql --> Demo.Entities
    Demo.InMemory --> Aiursoft.DbTools.InMemory
    Demo.InMemory --> Demo.Entities
    Demo.WebApp --> Aiursoft.DbTools.Switchable
    Demo.WebApp --> Demo.InMemory
    Demo.WebApp --> Demo.MySql
    Demo.WebApp --> Demo.Sqlite
    Aiursoft.DbTools.SqlServer --> Aiursoft.DbTools

Usage

In your startup.cs:

public void ConfigureServices(IConfiguration configuration, IWebHostEnvironment environment, IServiceCollection services)
{
    var (connectionString, dbType, allowCache) = configuration.GetDbSettings();
    services.AddSwitchableRelationalDatabase(
        dbType: EntryExtends.IsInUnitTests() ? "InMemory": dbType,
        connectionString: connectionString,
        supportedDbs:
        [
            new MySqlSupportedDb(allowCache: allowCache, splitQuery: false),
            new SqliteSupportedDb(allowCache: allowCache, splitQuery: true),
            new InMemorySupportedDb()
        ]);

    services
        .AddControllersWithViews()
        .AddApplicationPart(typeof(Startup).Assembly);
}

In your appsettings.json:

{
    "ConnectionStrings": {
        "AllowCache": "True",
        "DbType": "Sqlite",
        "DefaultConnection": "DataSource=app.db;Cache=Shared"
    }
}

Or:

{
  // sudo docker run -d --name db -e MYSQL_RANDOM_ROOT_PASSWORD=true -e MYSQL_DATABASE=kahla -e MYSQL_USER=kahla -e MYSQL_PASSWORD=kahla_password -p 3306:3306 hub.aiursoft.cn/mysql
  "ConnectionStrings": {
    "AllowCache": "True",
    "DbType": "MySql",
    "DefaultConnection": "Server=localhost;Database=kahla;Uid=kahla;Pwd=kahla_password;"
  }
}

Or:

{
  "ConnectionStrings": {
    "AllowCache": "False",
    "DbType": "InMemory"
  }
}

Simple, isn't it?

Your database project need to be different with your web project, you need the following command to generate migrations:

cd ./Demo.MySql
dotnet ef migrations add Init --context "MySqlContext" -s ../Demo.WebApp/Demo.WebApp.csproj
cd ..

cd ./Demo.Sqlite
dotnet ef migrations add Init --context "SqliteContext" -s ../Demo.WebApp/Demo.WebApp.csproj
cd ..

For more usage, please check the Demo app in the demos folder!

How to contribute

There are many ways to contribute to the project: logging bugs, submitting pull requests, reporting issues, and creating suggestions.

Even if you with push rights on the repository, you should create a personal fork and create feature branches there when you need them. This keeps the main repository clean and your workflow cruft out of sight.

We're also interested in your feedback on the future of this project. You can submit a suggestion or feature request through the issue tracker. To make this process more effective, we're asking that these include more information to help define them more clearly.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Aiursoft.DbTools.Sqlite:

Package Downloads
Aiursoft.Kahla.Sqlite

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.0.11 59 2/27/2025
9.0.10 52 2/27/2025
9.0.9 80 2/25/2025
9.0.8 75 2/23/2025
9.0.7 102 2/12/2025
9.0.6 119 2/1/2025
9.0.5 103 1/16/2025
9.0.4 60 1/15/2025
9.0.3 55 1/15/2025
9.0.1 71 1/14/2025
9.0.0 102 12/30/2024
8.0.28 141 12/11/2024
8.0.27 142 11/14/2024
8.0.26 106 11/13/2024
8.0.24 111 11/9/2024
8.0.23 119 10/26/2024
8.0.22 131 10/14/2024
8.0.21 108 10/9/2024
8.0.20 130 9/29/2024
8.0.19 103 9/28/2024
8.0.18 125 9/22/2024
8.0.17 146 8/22/2024
8.0.16 136 8/18/2024
8.0.15 120 7/23/2024
8.0.14 220 7/10/2024
8.0.13 118 7/7/2024
8.0.12 123 6/29/2024
8.0.11 134 6/5/2024
8.0.10 123 5/28/2024
8.0.9 130 5/16/2024
8.0.8 149 5/4/2024
8.0.7 148 4/6/2024
8.0.6 136 3/31/2024
8.0.5 110 3/31/2024
8.0.4 165 3/17/2024
8.0.3 119 3/17/2024
8.0.2 124 3/3/2024
8.0.1 121 2/25/2024
8.0.0 218 2/19/2024
7.0.25 156 2/14/2024
7.0.24 117 2/4/2024
7.0.23 120 2/2/2024
7.0.22 119 2/2/2024
7.0.21 121 1/30/2024
7.0.20 117 1/27/2024
7.0.19 131 1/21/2024
7.0.18 136 1/10/2024
7.0.17 131 1/4/2024
7.0.16 154 12/30/2023
7.0.15 139 12/24/2023
7.0.14 149 12/12/2023
7.0.13 125 12/12/2023
7.0.12 147 12/1/2023
7.0.11 141 11/26/2023
7.0.10 145 11/18/2023
7.0.9 133 11/12/2023
7.0.8 147 11/2/2023
7.0.7 133 11/2/2023
7.0.6 135 11/1/2023
7.0.5 123 10/31/2023
7.0.4 140 10/27/2023
7.0.3 149 10/18/2023
7.0.2 136 10/11/2023
7.0.1 148 9/13/2023
7.0.0 140 9/5/2023
6.0.32 156 8/4/2023
6.0.31 168 8/3/2023
6.0.30 168 7/11/2023
6.0.29 162 6/30/2023