BlazorChat.Server.SqlServer 1.0.1

There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package BlazorChat.Server.SqlServer --version 1.0.1
                    
NuGet\Install-Package BlazorChat.Server.SqlServer -Version 1.0.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="BlazorChat.Server.SqlServer" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorChat.Server.SqlServer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="BlazorChat.Server.SqlServer" />
                    
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 BlazorChat.Server.SqlServer --version 1.0.1
                    
#r "nuget: BlazorChat.Server.SqlServer, 1.0.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 BlazorChat.Server.SqlServer@1.0.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=BlazorChat.Server.SqlServer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=BlazorChat.Server.SqlServer&version=1.0.1
                    
Install as a Cake Tool

BlazorChat.Server.SqlServer

SQL Server persistence provider for BlazorChat.Server.

30-Day Free Trial — Start using immediately, purchase when ready.

Replaces in-memory storage with production-ready SQL Server database persistence for chat messages, user presence, and room management.

BlazorChat.Server is installed automatically as a dependency. A valid license key is required.

Prerequisites

  • BlazorChat.Server 1.0.0 or later (installed automatically as dependency)
  • SQL Server 2016 or later, or Azure SQL Database
  • DatabaseLibraryMDS (installed automatically as dependency)
  • Valid BlazorChat license key (30-day trial available)

Getting Started

No additional license needed! If you have a BlazorChat.Server license, this package is covered. Trial users can use this during the 30-day trial period.

Quick Start

1. Install Package

dotnet add package BlazorChat.Server.SqlServer

2. Create Database

Create a new database or use an existing database: -- Option 1: Create new database (recommended name: BlazorChatDb) CREATE DATABASE BlazorChatDb; GO -- Option 2: Use existing database -- Just update your connection string to point to your existing database

Note: You can use any database name. Update your connection string to match your chosen database name.

3. Export SQL Scripts

Export the schema scripts for review and execution:

// Export scripts to a folder for DBA review 
BlazorChatSqlServerScripts.ExportToFolder(@"C:\temp\BlazorChatScripts");

4. Run SQL Scripts

Execute the exported .sql files against your database using:

  • SQL Server Management Studio
  • Azure Data Studio
  • sqlcmd command-line tool
  • Your preferred SQL execution tool

5. Configure Connection String

Add to appsettings.json:

{
  "ConnectionStrings": {
	"BlazorChatSqlServer": "Server=your_server;Database=BlazorChatDb;User Id=your_user;Password=your_password;"
  }
}

Tip: Change Database=BlazorChatDb to match your existing database name if using a different database.

6. Update Program.cs

Configure the SQL Server persistence provider:

using BlazorChat.Server.SqlServer.Extensions; 
using DatabaseLibraryMDS; 
using DatabaseLibraryMDS.Interfaces;

var builder = WebApplication.CreateBuilder(args);
// Get connection string 
var dbConnectionString = builder.Configuration.GetConnectionString("BlazorChatDb"); if (string.IsNullOrWhiteSpace(dbConnectionString)) throw new InvalidOperationException("ConnectionStrings:BlazorChatDb is missing. Add it to User Secrets or appsettings.json.");

// Register DatabaseLibraryMDS 
builder.Services.AddScoped<ISqlServer, SqlServer>(provider => new SqlServer(dbConnectionString));

// Add Blazor components 
builder.Services.AddRazorComponents() 
	.AddInteractiveServerComponents();

// Add BlazorChat with SQL Server persistence 
builder.Services.AddBlazorChatSqlServer(builder.Configuration);

var app = builder.Build();
app.UseHttpsRedirection(); 
app.UseStaticFiles(); 
app.UseAntiforgery();
app.MapRazorComponents<App>() 
.AddInteractiveServerRenderMode();

// Map the BlazorChat SignalR hub 
app.MapBlazorChatHub();
app.Run();

Connection String Examples

Windows Authentication (Local Development)

{
  "ConnectionStrings": {
	"BlazorChatSqlServer": "Server=localhost;Database=BlazorChatDb;Trusted_Connection=True;"
  }
}

SQL Server Authentication

{
  "ConnectionStrings": {
	"BlazorChatSqlServer": "Server=your_server;Database=BlazorChatDb;User Id=your_user;Password=your_password;"
  }
}

Azure SQL Database

{
  "ConnectionStrings": {
	"BlazorChatSqlServer": "Server=tcp:your_server.database.windows.net,1433;Initial Catalog=BlazorChatDb;Persist Security Info=False;User ID=your_user;Password=your_password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
  }
}

Using Existing Database

Server=.;Database=MyExistingDb;Trusted_Connection=true;TrustServerCertificate=true;

Note: Replace BlazorChatDb with your actual database name in all connection strings.

Server=.;Database=BlazorChatDb;Trusted_Connection=true;Max Pool Size=100;Min Pool Size=10;Pooling=true;

Features

All BlazorChat.Server features, plus:

  • Persistent message history - Messages survive server restarts
  • User presence tracking - Online/offline status persisted across sessions
  • Room management - Multi-room support with persistent history
  • Exportable SQL scripts - Review and customize before deployment
  • Optimized indexes - Fast queries for message retrieval
  • Transaction support - ACID compliance for data integrity
  • Connection pooling - High-performance connection management
  • Azure SQL compatible - Works seamlessly with Azure SQL Database
  • Flexible database naming - Use BlazorChatDb or your existing database
  • Scalable architecture - Supports horizontal scaling with read replicas

Database Schema

Tables

The following tables are created by the provided SQL scripts:

Table Purpose
Messages Chat message storage with full history
ChatSenders User information and display names
Rooms Chat room metadata
UserPresence Active users and connection tracking
Reactions Message reactions and emoji responses

Indexes

Optimized indexes are included in the scripts for:

  • Message timestamps (for sorting)
  • Room IDs (for filtering)
  • Sender IDs (for user queries)
  • Connection IDs (for presence tracking)

Performance Optimization

Default Optimizations

  • Connection pooling enabled by default
  • Parameterized queries prevent SQL injection
  • Optimized indexes included in schema scripts
  • Async operations throughout for non-blocking I/O

Scaling for High Traffic

For high-traffic scenarios:

  1. Read Replicas - Configure read-only replicas for query load distribution
  2. Connection Pool Tuning - Adjust Max Pool Size based on load
  3. Azure SQL Elastic Pools - Share resources across multiple databases
  4. Table Partitioning - For very large message histories (custom implementation)

Configuration Options

Uses the same configuration as BlazorChat.Server:

{ 
	"ConnectionStrings": { 
		"BlazorChatDb": "Server=.;Database=BlazorChatDb;Trusted_Connection=true;" }, 
		"BlazorChat": { "LicenseKey": "your-license-key-here", 
		"LicenseApiUrl": "https://api.loneworx.com", 
		"PurchaseUrl": "https://loneworx.com/blazor-chat/pricing", 
		"Product": "BlazorChatServer", "Version": "1.0.0" } }

Option Description Default
LicenseKey Your purchased license key (JWT) null (triggers trial)
LicenseApiUrl License API endpoint for trial registration https://api.loneworx.com
PurchaseUrl Purchase page URL https://loneworx.com/blazor-chat/pricing
Product Product identifier for license validation BlazorChatServer
Version Product version Package version

See BlazorChat.Server documentation for full configuration options.

License Tiers

BlazorChat offers multiple licensing tiers:

  • Trial - 30 days, all features, automatic registration
  • SingleTenant - Production license for single-domain deployments
  • MultiTenant - Production license for multi-domain/SaaS deployments

See pricing page for details and feature comparison.

Troubleshooting

Connection Failures

Symptoms:

  • Server logs: "Unable to connect to SQL Server"
  • ConnectionStrings:BlazorChatDb is missing exception

Solutions:

  1. Verify SQL Server is running: sc query MSSQLSERVER
  2. Check firewall allows connections on port 1433
  3. Verify connection string in appsettings.json or User Secrets
  4. Test connection with SQL Server Management Studio
  5. Ensure database name in connection string matches your actual database

Database Does Not Exist

Symptoms:

  • Cannot open database "BlazorChatDb" requested by the login

Solutions:

  1. Create the database manually: CREATE DATABASE BlazorChatDb;
  2. Verify database name matches connection string exactly (case-sensitive on Linux/Azure)
  3. Check SQL login has access to the specified database

Schema Objects Missing

Symptoms:

  • Invalid object name 'Messages' or similar errors

Solutions:

  1. Export scripts: BlazorChatSqlServerScripts.ExportToFolder(@"C:\temp\BlazorChatScripts");
  2. Review exported .sql files
  3. Execute scripts against your database
  4. Verify SQL login has db_owner or appropriate CREATE TABLE permissions

Performance Issues

Symptoms:

  • Slow message loading
  • High database CPU usage
  • Connection pool exhaustion

Solutions:

  1. Verify indexes were created from the provided scripts
  2. Increase connection pool size: Add Max Pool Size=200; to connection string
  3. Review query execution plans in SSMS
  4. Consider read replicas for high read traffic
  5. Ensure statistics are up to date: UPDATE STATISTICS

Migration from In-Memory

To switch from in-memory to SQL Server:

  1. Install this package: dotnet add package BlazorChat.Server.SqlServer
  2. Create database or designate existing database
  3. Export and run the SQL scripts
  4. Update Program.cs to use AddBlazorChatSqlServer
  5. Add connection string to appsettings.json
  6. Register DatabaseLibraryMDS services
  7. Restart application

Note: Previous in-memory data is not automatically migrated (it was ephemeral).

API Reference

Extension Methods

AddBlazorChatSqlServer(IConfiguration)

Registers BlazorChat services with SQL Server persistence. Replaces the in-memory storage with SQL Server implementations of IChatRepository and IChatPresenceStore.

Usage:

builder.Services.AddBlazorChatSqlServer(builder.Configuration);
MapBlazorChatHub()

Maps the BlazorChat SignalR hub to /chathub endpoint.

SQL Script Utilities

BlazorChatSqlServerScripts.ExportToFolder(string folderPath)

Exports all SQL scripts to the specified folder for DBA review and execution.

Example:

// Export scripts to a folder for DBA review 
BlazorChatSqlServerScripts.ExportToFolder(@"C:\temp\BlazorChatScripts");
BlazorChatSqlServerScripts.GetAllSqlScripts()

Returns all SQL scripts as a collection for programmatic access.

Example:

var scripts = BlazorChatSqlServerScripts.GetAllSqlScripts().ToList(); 

foreach (var script in scripts) 
{ 
	Console.WriteLine($"Script: {script.Name}"); 
}

Support & Resources

📧 Email: support@loneworx.com
🌐 Website: loneworx.com
💰 Pricing: loneworx.com/blazor-chat/pricing
🎯 Live Demo: loneworx.com/blazor-chat-demo

For technical support or sales inquiries, contact us at support@loneworx.com

  • BlazorChat.Server (Required) - Core server components and licensing
  • BlazorChat (Community Edition) - GPLv3 in-memory chat components
  • BlazorChat.Shared - Shared models and contracts
  • DatabaseLibraryMDS (Required) - SQL Server data access library

License

Proprietary commercial software. Same license as BlazorChat.Server.

About LoneWorx

LoneWorx LLC - Crafting exceptional software solutions.

🌐 www.loneworx.com
📧 info@loneworx.com
📍 United States


Copyright © 2024-2026 LoneWorx LLC. All rights reserved.

BlazorChat™ is a trademark of LoneWorx LLC.

Product Compatible and additional computed target framework versions.
.NET 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.

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.0.2 30 3/9/2026