Aiursoft.DbTools.SqlServer
9.0.11
dotnet add package Aiursoft.DbTools.SqlServer --version 9.0.11
NuGet\Install-Package Aiursoft.DbTools.SqlServer -Version 9.0.11
<PackageReference Include="Aiursoft.DbTools.SqlServer" Version="9.0.11" />
paket add Aiursoft.DbTools.SqlServer --version 9.0.11
#r "nuget: Aiursoft.DbTools.SqlServer, 9.0.11"
// Install Aiursoft.DbTools.SqlServer as a Cake Addin #addin nuget:?package=Aiursoft.DbTools.SqlServer&version=9.0.11 // Install Aiursoft.DbTools.SqlServer as a Cake Tool #tool nuget:?package=Aiursoft.DbTools.SqlServer&version=9.0.11
DBTools
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 | Versions 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. |
-
net9.0
- Aiursoft.DbTools (>= 9.0.11)
- EFCoreSecondLevelCacheInterceptor.MemoryCache (>= 5.2.1)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Aiursoft.DbTools.SqlServer:
Repository | Stars |
---|---|
AiursoftWeb/Infrastructures
Mirror of: https://gitlab.aiursoft.cn/aiursoft/infrastructures
|
Version | Downloads | Last updated |
---|---|---|
9.0.11 | 36 | 2/27/2025 |
9.0.10 | 37 | 2/27/2025 |
9.0.9 | 71 | 2/25/2025 |
9.0.8 | 79 | 2/23/2025 |
9.0.7 | 92 | 2/12/2025 |
9.0.6 | 98 | 2/1/2025 |
9.0.5 | 86 | 1/16/2025 |
9.0.4 | 62 | 1/15/2025 |
9.0.3 | 64 | 1/15/2025 |
9.0.1 | 41 | 1/14/2025 |
9.0.0 | 96 | 12/30/2024 |
8.0.28 | 100 | 12/11/2024 |
8.0.27 | 100 | 11/14/2024 |
8.0.26 | 97 | 11/13/2024 |
8.0.24 | 96 | 11/9/2024 |
8.0.23 | 94 | 10/26/2024 |
8.0.22 | 93 | 10/14/2024 |
8.0.21 | 100 | 10/9/2024 |
8.0.20 | 103 | 9/29/2024 |
8.0.19 | 99 | 9/28/2024 |
8.0.18 | 104 | 9/22/2024 |
8.0.17 | 147 | 8/22/2024 |
8.0.16 | 131 | 8/18/2024 |
8.0.15 | 101 | 7/23/2024 |
8.0.14 | 112 | 7/10/2024 |
8.0.13 | 119 | 7/7/2024 |
8.0.12 | 118 | 6/29/2024 |
8.0.11 | 113 | 6/5/2024 |
8.0.10 | 116 | 5/28/2024 |
8.0.9 | 127 | 5/16/2024 |
8.0.8 | 133 | 5/4/2024 |
8.0.7 | 129 | 4/6/2024 |
8.0.6 | 129 | 3/31/2024 |
8.0.5 | 122 | 3/31/2024 |
8.0.4 | 111 | 3/17/2024 |
8.0.3 | 123 | 3/17/2024 |
8.0.2 | 143 | 3/3/2024 |
8.0.1 | 138 | 2/25/2024 |
8.0.0 | 482 | 2/19/2024 |
7.0.25 | 147 | 2/14/2024 |
7.0.24 | 124 | 2/4/2024 |
7.0.23 | 115 | 2/2/2024 |
7.0.22 | 106 | 2/2/2024 |
7.0.21 | 114 | 1/30/2024 |
7.0.20 | 119 | 1/27/2024 |
7.0.19 | 141 | 1/21/2024 |
7.0.18 | 143 | 1/10/2024 |
7.0.17 | 139 | 1/4/2024 |
7.0.16 | 935 | 12/30/2023 |
7.0.15 | 161 | 12/24/2023 |
7.0.14 | 156 | 12/12/2023 |
7.0.13 | 136 | 12/12/2023 |
7.0.12 | 162 | 12/1/2023 |
7.0.11 | 320 | 11/26/2023 |
7.0.10 | 345 | 11/18/2023 |
7.0.9 | 214 | 11/12/2023 |
7.0.8 | 271 | 11/2/2023 |
7.0.7 | 163 | 11/2/2023 |
7.0.6 | 185 | 11/1/2023 |
7.0.5 | 209 | 10/31/2023 |
7.0.4 | 177 | 10/27/2023 |
7.0.3 | 217 | 10/18/2023 |
7.0.2 | 244 | 10/11/2023 |
7.0.1 | 399 | 9/13/2023 |
7.0.0 | 303 | 9/5/2023 |
6.0.32 | 229 | 8/4/2023 |
6.0.31 | 190 | 8/3/2023 |
6.0.30 | 206 | 7/11/2023 |
6.0.29 | 437 | 6/30/2023 |