Mma.SqlStudio.ApiClient 1.4.1

dotnet add package Mma.SqlStudio.ApiClient --version 1.4.1
                    
NuGet\Install-Package Mma.SqlStudio.ApiClient -Version 1.4.1
                    
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="Mma.SqlStudio.ApiClient" Version="1.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mma.SqlStudio.ApiClient" Version="1.4.1" />
                    
Directory.Packages.props
<PackageReference Include="Mma.SqlStudio.ApiClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mma.SqlStudio.ApiClient --version 1.4.1
                    
#r "nuget: Mma.SqlStudio.ApiClient, 1.4.1"
                    
#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.
#:package Mma.SqlStudio.ApiClient@1.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mma.SqlStudio.ApiClient&version=1.4.1
                    
Install as a Cake Addin
#tool nuget:?package=Mma.SqlStudio.ApiClient&version=1.4.1
                    
Install as a Cake Tool

Mma.SqlStudio.ApiClient

Mma.SqlStudio Logo

A modern, highly customizable, embeddable SQL Server Object Explorer and Query Editor for .NET.

NuGet .NET License


Mma.SqlStudio.ApiClient is a Razor Class Library (RCL) that allows you to easily embed a full-featured SQL development environment into any ASP.NET Core application. It connects to a backend API to execute queries and manage database schema, providing a decoupled and secure way to interact with your data.

✨ Features

  • 🗄️ SQL Object Explorer: Browse databases, schemas, tables, views, and stored procedures seamlessly.
  • ✍️ Query Editor: Execute queries with full syntax highlighting and a responsive results grid.
  • 🎨 Modern UI: Clean, responsive, and dynamic interface built with vanilla CSS. Dark and Light mode supported!
  • 🔌 Embeddable: Drop into any ASP.NET Core application via Minimal APIs and Razor Pages in just a few lines of code.
  • ⚙️ Highly Configurable: Control routing, application naming, and schema loading.
  • 🕒 Query History: Dedicated sidebar tab for query history, including browser metadata (cookies/localStorage) and easy script re-execution.
  • 🔒 Customizable Authorization: Secure your SQL Studio instance by applying custom endpoint and page authorization filters, including built-in support for HTTP Basic Auth.

🚀 Getting Started

1. Install the NuGet Package

Add the package to your project using the .NET CLI:

dotnet add package Mma.SqlStudio.ApiClient --version 1.4.1

2. Configure Services

Register the required services in your Program.cs. You can customize the studio behavior by configuring the SqlStudioOptions.

builder.Services.AddRazorPages();

// Configure the HttpClient that SQL Studio will use to talk to your backend API
builder.Services.AddHttpClient("SqlStudioClient", client =>
{
    client.BaseAddress = new Uri("https://your-api-url.com");
});

// Add and configure SQL Studio
builder.Services.AddSqlStudio(options => 
{
    options.Route = "/sql-studio";
    options.AppName = "Mma SQL Studio";
    
    options.ApiConfig = new()
    {
        QueryEndPoint = "api/sql/query",
        ExecuteEndPoint = "api/sql/execute",
        SchemaEndPoint = "api/sql/schema",
        HealthEndpoint = "api/health",
        AuthHeaders = new Dictionary<string, string>
        {
            { "X-Api-Key", "your-secret-key" }
        }
    };
    
    // Optional: UI Configuration
    options.EnableSchemaLoad = true;
    options.Theme = "Dark"; // "Dark" or "Light"
    
    // Optional: Object Filtering
    options.ExcludedSchemas = ["guest", "temp"]; 
    options.ExcludedObjects = ["Logs", "InternalTable"];
    
    // Optional: Authorization Filter for the UI pages
    options.AuthFilter = ctx => 
    {
        // Example: HTTP Basic Auth (admin:password)
        if (ctx.Request.Headers.TryGetValue("Authorization", out var authHeader) && 
            authHeader.ToString().StartsWith("Basic "))
        {
            var token = authHeader.ToString().Substring("Basic ".Length).Trim();
            return token == "YWRtaW46cGFzc3dvcmQ=";
        }
        
        ctx.Response.Headers.WWWAuthenticate = "Basic realm=\"SqlStudio\"";
        return false;
    };
    
    // History Configuration
    options.AllowHistoryLog = true;
    options.HistoryTableName = "__SqlStudioQueryHistory";
    options.CreateTable = true; // Auto-provision history table
    
    // Set to null to return 401 Unauthorized instead of redirecting
    options.UnauthorizedRedirectUrl = null;
});

3. Map Endpoints

Ensure static files and endpoints are mapped properly in your middleware pipeline:

// Required to serve the embedded CSS and JS files from the RCL
app.UseStaticFiles(); 

app.MapRazorPages();

// Map the API endpoints required by SQL Studio (Proxies to your configured API)
app.MapSqlStudioEndpoints();

🔌 API Specification

Your backend API must implement the following endpoints. You can find the full OpenAPI Specification (YAML) in the repository.

Response Models

All query/execute endpoints should return a QueryResult object:

{
  "success": true,
  "isQuery": true,
  "message": "Query executed successfully",
  "rows": [
    { "Id": 1, "Name": "Alice" },
    { "Id": 2, "Name": "Bob" }
  ]
}

1. Query Endpoint (POST)

Used for SELECT statements.

  • Request: { "query": "string", "cookies": "string", "localStorage": "string" }
  • Response: QueryResult (rows populated)

2. Execute Endpoint (POST)

Used for INSERT, UPDATE, DELETE, etc.

  • Request: { "query": "string", "cookies": "string", "localStorage": "string" }
  • Response: QueryResult (rows usually empty)

3. History Endpoint (GET)

Retrieves query history.

  • Response: { "items": [HistoryItem], "tableName": "string" }

3. Schema Endpoint (GET)

Returns the database structure.

  • Response: Array of SchemaNode:
[
  {
    "name": "dbo",
    "children": [
      { "name": "Tables", "objects": ["Users", "Orders"] },
      { "name": "Views", "objects": ["v_ActiveUsers"] }
    ]
  }
]

4. Health Endpoint (GET)

Simple check to verify backend connectivity.

  • Response: Any 2xx status code.

📸 Screenshots

Dark Theme dark theme

Light Theme light theme

📝 License

This project is licensed under the MIT License. See the LICENSE file for details.

Product 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.  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.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

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
1.4.1 93 5/11/2026
1.3.2 92 5/3/2026
1.3.1 91 5/3/2026