Aiursoft.DbTools 8.0.5

DBTools

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

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.

Showing the top 20 packages that depend on Aiursoft.DbTools.

Packages Downloads
Aiursoft.DbTools.InMemory
A tool for database.
72
Aiursoft.DbTools.Sqlite
A tool for database.
63
Aiursoft.DbTools.SqlServer
A tool for database.
59
Aiursoft.DbTools.InMemory
A tool for database.
57
Aiursoft.DbTools.Sqlite
A tool for database.
54
Aiursoft.DbTools.InMemory
A tool for database.
43
Aiursoft.DbTools.SqlServer
A tool for database.
42
Aiursoft.DbTools.Sqlite
A tool for database.
42
Aiursoft.DbTools.Sqlite
A tool for database.
29
Aiursoft.DbTools.MySql
A tool for database.
28
Aiursoft.DbTools.InMemory
A tool for database.
28
Aiursoft.DbTools.MySql
A tool for database.
27
Aiursoft.DbTools.MySql
A tool for database.
16
Aiursoft.DbTools.SqlServer
A tool for database.
15
Aiursoft.DbTools.Sqlite
A tool for database.
12
Aiursoft.DbTools.MySql
A tool for database.
9
Aiursoft.DbTools.SqlServer
A tool for database.
8
Aiursoft.DbTools.Sqlite
A tool for database.
6
Aiursoft.DbTools.InMemory
A tool for database.
6

Version Downloads Last updated
8.0.5 6 05/16/2024
8.0.4 42 05/04/2024
8.0.3 150 03/26/2024
8.0.2 2 03/29/2024
8.0.1 2 03/30/2024
8.0.0 43 03/25/2024
7.0.19 1 04/29/2024
7.0.18 2 04/29/2024
7.0.17 3 04/28/2024
7.0.16 1 04/29/2024
7.0.15 1 04/29/2024
7.0.14 2 04/29/2024
7.0.13 1 04/29/2024
7.0.12 56 03/26/2024
7.0.11 1 04/29/2024
7.0.10 1 04/29/2024
7.0.9 1 04/29/2024
7.0.8 1 04/29/2024
7.0.7 1 04/29/2024
7.0.6 1 04/29/2024
7.0.5 1 04/29/2024
7.0.4 2 04/12/2024
7.0.3 1 04/29/2024
7.0.2 1 04/29/2024
7.0.1 1 04/29/2024
7.0.0 1 04/29/2024
6.0.32 1 04/29/2024
6.0.31 1 04/29/2024
6.0.30 0 07/11/2023
6.0.29 1 04/29/2024
6.0.28 1 04/29/2024
6.0.27 1 04/29/2024
6.0.26 2 04/29/2024
6.0.25 1 04/29/2024
6.0.24 1 04/29/2024
6.0.23 1 04/29/2024
6.0.22 1 04/29/2024
6.0.21 1 04/29/2024
6.0.20 1 04/29/2024
6.0.19 3 03/28/2024
6.0.18 1 04/29/2024
6.0.17 1 04/29/2024
6.0.16 1 04/29/2024
6.0.15 2 04/23/2024
6.0.14 1 04/29/2024
6.0.13 1 04/29/2024
6.0.12 2 04/07/2024
6.0.11 1 04/29/2024
6.0.10 1 04/29/2024
6.0.9 1 04/29/2024
6.0.8 1 04/29/2024
6.0.7 1 04/29/2024
6.0.6 1 04/29/2024
6.0.5 1 04/29/2024
6.0.0 1 04/29/2024
5.0.9 1 04/29/2024
5.0.8 1 04/29/2024
5.0.7 1 04/29/2024
5.0.6 2 04/04/2024
5.0.5 1 04/29/2024
5.0.4 1 04/29/2024
5.0.3 1 04/29/2024
5.0.2 1 04/29/2024
5.0.1 2 04/26/2024
5.0.0 1 04/29/2024
3.2.11 1 04/29/2024
3.2.10 1 04/29/2024
3.2.9 1 04/29/2024
3.2.8 1 04/29/2024
3.2.7 1 04/29/2024
3.2.6 1 04/29/2024
3.2.5 1 04/29/2024
3.2.4 1 04/29/2024
3.2.3 2 04/29/2024
3.2.2 1 04/29/2024
3.2.1 1 04/29/2024
3.2.0 1 04/29/2024
3.1.14 1 04/29/2024
3.1.13 1 04/29/2024
3.1.12 2 04/08/2024
3.1.11 1 04/29/2024
3.1.10 2 04/14/2024
3.1.9 1 04/29/2024
3.1.8 1 04/29/2024
3.1.7 1 04/29/2024
3.1.6 1 04/29/2024
3.1.5 1 04/29/2024
3.1.4 1 04/29/2024