![]() |
VOOZH | about |
dotnet add package CosmoSQLClient.MySql.EntityFrameworkCore --version 6.3.1
NuGet\Install-Package CosmoSQLClient.MySql.EntityFrameworkCore -Version 6.3.1
<PackageReference Include="CosmoSQLClient.MySql.EntityFrameworkCore" Version="6.3.1" />
<PackageVersion Include="CosmoSQLClient.MySql.EntityFrameworkCore" Version="6.3.1" />Directory.Packages.props
<PackageReference Include="CosmoSQLClient.MySql.EntityFrameworkCore" />Project file
paket add CosmoSQLClient.MySql.EntityFrameworkCore --version 6.3.1
#r "nuget: CosmoSQLClient.MySql.EntityFrameworkCore, 6.3.1"
#:package CosmoSQLClient.MySql.EntityFrameworkCore@6.3.1
#addin nuget:?package=CosmoSQLClient.MySql.EntityFrameworkCore&version=6.3.1Install as a Cake Addin
#tool nuget:?package=CosmoSQLClient.MySql.EntityFrameworkCore&version=6.3.1Install as a Cake Tool
A lightweight, high-performance database client library for .NET designed for low-latency, high-throughput applications. CosmoSQLClient provides a unified interface for multiple database engines while minimizing memory allocations and binary footprint.
| Package | NuGet |
|---|---|
CosmoSQLClient.Core |
👁 NuGet |
CosmoSQLClient.MsSql |
👁 NuGet |
CosmoSQLClient.Postgres |
👁 NuGet |
CosmoSQLClient.MySql |
👁 NuGet |
CosmoSQLClient.Sqlite |
👁 NuGet |
CosmoSQLClient.CosmoKv |
👁 NuGet |
CosmoSQLClient.CosmoKvHttp |
👁 NuGet |
CosmoSQLClient.CosmoKv.Cli (dotnet tool: cosmokv) |
👁 NuGet |
CosmoSQLClient.MsSql.EntityFrameworkCore |
👁 NuGet |
CosmoSQLClient.Postgres.EntityFrameworkCore |
👁 NuGet |
CosmoSQLClient.MySql.EntityFrameworkCore |
👁 NuGet |
CosmoSQLClient.Sqlite.EntityFrameworkCore |
👁 NuGet |
System.IO.Pipelines for efficient asynchronous I/O and protocol decoding.struct-based token handlers to eliminate boxing and reduce heap pressure.IAsyncEnumerable for row-by-row processing, ideal for large datasets and reactive streams.ISqlDatabase interface across all supported engines (MSSQL, PostgreSQL, MySQL, SQLite, CosmoKv, CosmoKvHttp).| Engine | Protocol | Supported Features |
|---|---|---|
| MSSQL | TDS 7.x | Integrated Security (NTLMv2), Stored Procedures, Transactions, Named Instances |
| PostgreSQL | Frontend/Backend 3.0 | MD5/Scram-SHA-256 Auth, Transactions, Parameterized Queries |
| MySQL | MySQL Protocol 4.1+ | Standard Auth, Transactions, Parameterized Queries |
| SQLite | Local File | Native engine integration, Online Backup, Transactions |
| CosmoKv (embedded) | In-process facade over the CosmoNova engine (T-SQL parser + executor + LSM storage in one assembly) | Full T-SQL subset, MVCC transactions, online COSMOBAK backup |
| CosmoKvHttp | HTTP/JSON wire to a CosmoKvD daemon | Same T-SQL surface as CosmoKv, exposed over the network for multi-process sharing |
| CosmoKvPipes | Unix-pipes wire to a CosmoKvD daemon | Same T-SQL surface as CosmoKvHttp; faster than HTTP for co-located processes |
Starting at v6.0, CosmoSQLClient.CosmoKv is a thin ISqlDatabase facade (~250 LOC). The T-SQL engine that used to live in this package was extracted into the standalone CosmoNova package (storage + engine in one assembly); this driver depends on it and exposes the connection API via CosmoKvConnection / CosmoKvConfiguration.
using CosmoSQLClient.CosmoKv;
await using var conn = await CosmoKvConnection.OpenAsync(
new CosmoKvConfiguration { DataSource = "/var/lib/myapp" });
await conn.ExecuteAsync("CREATE TABLE users (id BIGINT IDENTITY PRIMARY KEY, name VARCHAR(64));");
await conn.ExecuteAsync(
"INSERT INTO users (name) VALUES (@n);",
new List<SqlParameter> { SqlParameter.Named("@n", SqlValue.From("Ada")) });
var rows = await conn.QueryAsync("SELECT * FROM users;");
The supported T-SQL surface (as of CosmoNova 1.0+) is documented in the CosmoNova README. Highlights: full DDL (CREATE TABLE/INDEX with IF NOT EXISTS), JOIN (INNER/LEFT/RIGHT/FULL/CROSS), GROUP BY + GROUPING SETS, PIVOT/UNPIVOT, CTEs, windowed functions, IDENTITY, UNIQUE/PRIMARY KEY constraints, OUTPUT clauses, MERGE, scalar UDFs, stored procedures, triggers (subset), OPTION (RECOMPILE|FORCE ORDER|MAXDOP n) hints, hash join + cost-based join reordering. Embedded benchmarks show 32–60× faster than SQL Server 2025 on the same T-SQL.
Exceptions thrown by the engine (SqlTransactionConflictException, UniqueConstraintViolationException) live in the CosmoNova.Sql namespace as of v6.0. If your code catches them, add using CosmoNova.Sql; where needed.
Add the package for your specific database engine:
dotnet add package CosmoSQLClient.MsSql
dotnet add package CosmoSQLClient.Postgres
dotnet add package CosmoSQLClient.MySql
dotnet add package CosmoSQLClient.Sqlite
dotnet add package CosmoSQLClient.CosmoKv # embedded T-SQL on CosmoKv
dotnet add package CosmoSQLClient.CosmoKvHttp # T-SQL over HTTP to CosmoKvD
For Entity Framework Core integration, install the matching bridge package for your provider:
dotnet add package CosmoSQLClient.MsSql.EntityFrameworkCore
dotnet add package CosmoSQLClient.Postgres.EntityFrameworkCore
dotnet add package CosmoSQLClient.MySql.EntityFrameworkCore
dotnet add package CosmoSQLClient.Sqlite.EntityFrameworkCore
| Provider package | EF Core bridge package | Extension method |
|---|---|---|
CosmoSQLClient.MsSql |
CosmoSQLClient.MsSql.EntityFrameworkCore |
UseCosmoSqlServer(...) |
CosmoSQLClient.Postgres |
CosmoSQLClient.Postgres.EntityFrameworkCore |
UseCosmoPostgres(...) |
CosmoSQLClient.MySql |
CosmoSQLClient.MySql.EntityFrameworkCore |
UseCosmoMySql(...) |
CosmoSQLClient.Sqlite |
CosmoSQLClient.Sqlite.EntityFrameworkCore |
UseCosmoSqlite(...) |
using CosmoSQLClient.MsSql;
var connStr = "Server=localhost;Database=Sales;User Id=sa;Password=your_password;";
await using var conn = await MsSqlConnection.OpenAsync(connStr);
await using var cmd = conn.CreateCommand("SELECT TOP 10 * FROM Invoices");
await using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
var total = reader.GetDecimal("TotalAmount");
Console.WriteLine($"Invoice Total: {total}");
}
using CosmoSQLClient.CosmoKv;
using CosmoSQLClient.Core;
await using var conn = await CosmoKvConnection.OpenAsync(
new CosmoKvConfiguration { DataSource = "/var/lib/app/db" });
await conn.ExecuteAsync("""
CREATE TABLE IF NOT EXISTS Users (
Id BIGINT IDENTITY PRIMARY KEY,
Email NVARCHAR(256) NOT NULL,
CreatedAt DATETIME2 NOT NULL DEFAULT GETUTCDATE())
""");
// INSERT … OUTPUT returns the just-allocated IDENTITY.
var inserted = await conn.QueryAsync(
"INSERT INTO Users (Email) OUTPUT INSERTED.Id VALUES (@e)",
new[] { SqlParameter.Named("@e", SqlValue.From("alice@d.com")) });
long newId = inserted[0]["Id"].AsInt() ?? 0;
// INNER JOIN with qualified column refs.
var rows = await conn.QueryAsync(
"SELECT u.Email FROM Users u JOIN Mailboxes m ON m.UserId = u.Id");
Rows are yielded as they arrive from the socket, ensuring the full result set is never buffered in memory.
await foreach (var row in conn.Advanced.QueryStreamAsync("SELECT * FROM LargeTable"))
{
var id = row["Id"].AsInt32();
// Process one row at a time
}
CosmoSQLClient can be used as the underlying DbConnection for the standard EF Core relational providers. Install the matching EF Core bridge package, then configure your DbContext with the Cosmo-specific extension for that database.
using Microsoft.EntityFrameworkCore;
services.AddDbContext<AppDbContext>(options =>
options.UseCosmoSqlServer("Server=localhost;Database=Sales;User Id=sa;Password=your_password;TrustServerCertificate=True;"));
services.AddDbContext<AppDbContext>(options =>
options.UseCosmoPostgres("Host=localhost;Database=Sales;User Id=postgres;Password=your_password;"));
services.AddDbContext<AppDbContext>(options =>
options.UseCosmoMySql(
"Host=localhost;Database=Sales;User Id=root;Password=your_password;",
new MySqlServerVersion(new Version(8, 0, 0))));
services.AddDbContext<AppDbContext>(options =>
options.UseCosmoSqlite("Data Source=sales.db"));
cosmokvA sqlite3-style shell for CosmoKv embedded databases — REPL, one-shot SQL, stdin scripts, and four output formats. Ships as a dotnet global tool.
dotnet tool install -g CosmoSQLClient.CosmoKv.Cli
cosmokv ./mydb # REPL
cosmokv ./mydb "SELECT * FROM Users" # one-shot
cat schema.sql | cosmokv ./mydb - # stdin script
cosmokv --format=json ./mydb "SELECT * FROM Users" # JSON output
REPL dot-commands cover the usual introspection surface (.tables, .schema [TABLE], .indexes [TABLE], .dump, .format FMT, .quit). Full reference: .
The introspection used by .schema / .dump is also available programmatically from v2.5 — CosmoKvConnection.GetTableNames(), GetTableScript(name), GetIndexScriptsForTable(name), ScriptSchema() — so you can build your own dump/backup tooling without going through the CLI.
CosmoSQLClient implements a generic protocol decoder (ProcessTokensAsync) using struct handlers. This architecture ensures:
SqlRow and SqlValue types are never cast to object during decoding.CosmoSQLClient avoids heavy dependencies like Azure.Identity, MSAL, or Microsoft.Data.SqlClient.SNI.
| Library | Published Footprint |
|---|---|
| CosmoSQLClient.MsSql | ~207 KB |
| Microsoft.Data.SqlClient | ~17 MB+ |
SqlValue is the universal cell type returned by advanced query methods. It wraps the raw wire value and provides typed accessors:
SqlValue Accessor |
.NET Type |
|---|---|
AsInt32() / AsInt64() |
int / long |
AsString() |
string |
AsDecimal() |
decimal |
AsDouble() / AsFloat() |
double / float |
AsBoolean() |
bool |
AsDateTime() / AsDateTimeOffset() |
DateTime / DateTimeOffset |
AsGuid() |
Guid |
AsBytes() |
byte[] |
IsNull |
bool |
Supports native NTLMv2 authentication for Windows/Linux environments without external dependencies.
var connStr = "Server=myserver;Integrated Security=SSPI;Trust Server Certificate=true;";
await using var conn = await MsSqlConnection.OpenAsync(connStr);
Stream query results directly to a PipeWriter or Stream as JSON with zero intermediate allocations.
await conn.Advanced.QueryJsonStreamAsync(
"SELECT * FROM Users",
pipeWriter,
format: JsonOutputFormat.Array);
var result = await conn.Advanced.ExecuteProcAsync("GetCustomerInvoices", new {
CustomerId = 123,
Year = 2024
});
Licensed under the .
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.3.1 | 86 | 6/16/2026 |
| 6.3.0 | 106 | 6/16/2026 |
| 6.2.9 | 91 | 6/14/2026 |
| 6.2.8 | 99 | 6/14/2026 |
| 6.2.7 | 105 | 5/29/2026 |
| 6.2.6 | 112 | 5/29/2026 |
| 6.2.5 | 93 | 5/28/2026 |
| 6.2.4 | 107 | 5/28/2026 |
| 6.2.3 | 105 | 5/28/2026 |
| 6.2.2 | 109 | 5/28/2026 |
| 6.2.1 | 91 | 5/28/2026 |
| 6.2.0 | 97 | 5/26/2026 |
| 6.1.9 | 93 | 5/26/2026 |
| 6.1.8 | 96 | 5/26/2026 |
| 6.1.7 | 100 | 5/26/2026 |
| 6.1.6 | 96 | 5/26/2026 |
| 6.1.5 | 89 | 5/26/2026 |
| 6.1.4 | 100 | 5/26/2026 |
| 6.1.3 | 96 | 5/26/2026 |
| 6.1.2 | 90 | 5/26/2026 |