Aiursoft.DbTools.Switchable
8.0.15
See the version list below for details.
dotnet add package Aiursoft.DbTools.Switchable --version 8.0.15
NuGet\Install-Package Aiursoft.DbTools.Switchable -Version 8.0.15
<PackageReference Include="Aiursoft.DbTools.Switchable" Version="8.0.15" />
paket add Aiursoft.DbTools.Switchable --version 8.0.15
#r "nuget: Aiursoft.DbTools.Switchable, 8.0.15"
// Install Aiursoft.DbTools.Switchable as a Cake Addin #addin nuget:?package=Aiursoft.DbTools.Switchable&version=8.0.15 // Install Aiursoft.DbTools.Switchable as a Cake Tool #tool nuget:?package=Aiursoft.DbTools.Switchable&version=8.0.15
DBTools
DbTools are Aiursoft's common database tools. It contains a lot of useful database tools for developers.
Installation
To install Aiursoft.DbTools
to your project from nuget.org:
dotnet add package Aiursoft.DbTools
Usage
Easier to register DbContext:
SQLite
var services = new ServiceCollection();
services.AddAiurSqliteWithCache<MyDbContext>("Data Source=app.db");
var built = services.BuildServiceProvider();
var context = built.GetRequiredService<MyDbContext>();
SQL Server
var services = new ServiceCollection();
services.AddAiurSqlServerWithCache<MyDbContext>("Server=(localdb)\\mssqllocaldb;Database=DebugTrusted_Connection=True;MultipleActiveResultSets=true");
var built = services.BuildServiceProvider();
var context = built.GetRequiredService<MyDbContext>();
Easier to update database:
var hostBuilder = Host.CreateDefaultBuilder();
hostBuilder.ConfigureServices(services =>
services.AddAiurSqliteWithCache<MyDbContext>(@"DataSource=app.db;Cache=Shared")
);
var host = hostBuilder.Build();
// Now update:
await host.UpdateDbAsync<MyDbContext>(UpdateMode.CreateThenUse);
Switchable database
Supports:
- Sqlite
- MySql
- InMemory
First, install the package:
dotnet add package Aiursoft.DbTools.Switchable
In your appsettings.json
:
{
// Database.
"ConnectionStrings": {
"AllowCache": "True",
"DbType": "Sqlite",
"DefaultConnection": "DataSource=app.db;Cache=Shared"
},
}
In your startup.cs
:
var connectionString = configuration.GetConnectionString("DefaultConnection");
var dbType = configuration.GetSection("ConnectionStrings:DbType").Get<DbType>();
var allowCache = configuration.GetSection("ConnectionStrings:AllowCache").Get<bool>();
services.AddDatabase<MyDbContext>(connectionString, dbType, allowCache);
Tips
If your database project is different with your web project, you may need the following command to generate migrations:
cd ./DatabaseProject
dotnet ef migrations add MigrationName --context YourContext --output-dir Migrations --startup-project ../WebProject
dotnet ef database update --context YourContext
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 | 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. |
-
net8.0
- Aiursoft.DbTools.InMemory (>= 8.0.10)
- Aiursoft.DbTools.MySql (>= 8.0.19)
- Aiursoft.DbTools.Sqlite (>= 8.0.18)
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 |
---|---|---|
8.0.26 | 34 | 11/14/2024 |
8.0.25 | 55 | 11/13/2024 |
8.0.23 | 75 | 11/9/2024 |
8.0.22 | 77 | 10/26/2024 |
8.0.21 | 77 | 10/15/2024 |
8.0.20 | 75 | 10/14/2024 |
8.0.19 | 83 | 10/9/2024 |
8.0.18 | 81 | 10/7/2024 |
8.0.17 | 94 | 9/29/2024 |
8.0.16 | 82 | 9/28/2024 |
8.0.15 | 86 | 9/22/2024 |
8.0.14 | 127 | 8/22/2024 |
8.0.13 | 120 | 8/18/2024 |
8.0.12 | 99 | 7/23/2024 |
8.0.11 | 95 | 7/10/2024 |
8.0.10 | 109 | 7/7/2024 |
8.0.9 | 117 | 6/29/2024 |
8.0.8 | 105 | 6/5/2024 |
8.0.7 | 108 | 5/28/2024 |
8.0.6 | 111 | 5/16/2024 |
8.0.5 | 119 | 5/4/2024 |
8.0.4 | 137 | 4/6/2024 |
8.0.3 | 119 | 3/31/2024 |
8.0.2 | 118 | 3/31/2024 |
8.0.1 | 122 | 3/25/2024 |
8.0.0 | 122 | 3/25/2024 |