BlazorChat.Server.SqlServer
1.0.1
See the version list below for details.
dotnet add package BlazorChat.Server.SqlServer --version 1.0.1
NuGet\Install-Package BlazorChat.Server.SqlServer -Version 1.0.1
<PackageReference Include="BlazorChat.Server.SqlServer" Version="1.0.1" />
<PackageVersion Include="BlazorChat.Server.SqlServer" Version="1.0.1" />
<PackageReference Include="BlazorChat.Server.SqlServer" />
paket add BlazorChat.Server.SqlServer --version 1.0.1
#r "nuget: BlazorChat.Server.SqlServer, 1.0.1"
#:package BlazorChat.Server.SqlServer@1.0.1
#addin nuget:?package=BlazorChat.Server.SqlServer&version=1.0.1
#tool nuget:?package=BlazorChat.Server.SqlServer&version=1.0.1
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
sqlcmdcommand-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=BlazorChatDbto 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
BlazorChatDbwith your actual database name in all connection strings.
Connection Pooling (Recommended)
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:
- Read Replicas - Configure read-only replicas for query load distribution
- Connection Pool Tuning - Adjust
Max Pool Sizebased on load - Azure SQL Elastic Pools - Share resources across multiple databases
- 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 missingexception
Solutions:
- Verify SQL Server is running:
sc query MSSQLSERVER - Check firewall allows connections on port 1433
- Verify connection string in
appsettings.jsonor User Secrets - Test connection with SQL Server Management Studio
- Ensure database name in connection string matches your actual database
Database Does Not Exist
Symptoms:
Cannot open database "BlazorChatDb" requested by the login
Solutions:
- Create the database manually:
CREATE DATABASE BlazorChatDb; - Verify database name matches connection string exactly (case-sensitive on Linux/Azure)
- Check SQL login has access to the specified database
Schema Objects Missing
Symptoms:
Invalid object name 'Messages'or similar errors
Solutions:
- Export scripts:
BlazorChatSqlServerScripts.ExportToFolder(@"C:\temp\BlazorChatScripts"); - Review exported
.sqlfiles - Execute scripts against your database
- Verify SQL login has
db_owneror appropriateCREATE TABLEpermissions
Performance Issues
Symptoms:
- Slow message loading
- High database CPU usage
- Connection pool exhaustion
Solutions:
- Verify indexes were created from the provided scripts
- Increase connection pool size: Add
Max Pool Size=200;to connection string - Review query execution plans in SSMS
- Consider read replicas for high read traffic
- Ensure statistics are up to date:
UPDATE STATISTICS
Migration from In-Memory
To switch from in-memory to SQL Server:
- Install this package:
dotnet add package BlazorChat.Server.SqlServer - Create database or designate existing database
- Export and run the SQL scripts
- Update
Program.csto useAddBlazorChatSqlServer - Add connection string to
appsettings.json - Register
DatabaseLibraryMDSservices - 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
Related Packages
- 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 | Versions 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. |
-
net10.0
- BlazorChat.Server (>= 1.0.1)
- DatabaseLibraryMDS (>= 3.0.13)
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 |