BlazorChat.Server.SqlServer 1.0.3

dotnet add package BlazorChat.Server.SqlServer --version 1.0.3
                    
NuGet\Install-Package BlazorChat.Server.SqlServer -Version 1.0.3
                    
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.3" />
                    
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.3" />
                    
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.3
                    
#r "nuget: BlazorChat.Server.SqlServer, 1.0.3"
                    
#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.3
                    
#: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.3
                    
Install as a Cake Addin
#tool nuget:?package=BlazorChat.Server.SqlServer&version=1.0.3
                    
Install as a Cake Tool

BlazorChat.Server.SqlServer

SQL Server persistence provider for BlazorChat.Server.

30-Day Free Trial — covered by your BlazorChat.Server trial. No additional license needed.

Replaces in-memory storage with SQL Server persistence for messages and reactions. BlazorChat.Server is installed automatically as a dependency.

🚀 Quick Start

dotnet add package BlazorChat.Server.SqlServer

1. Export & Run SQL Scripts

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

Execute the exported .sql files against your database using SSMS, Azure Data Studio, or sqlcmd.

2. Add Connection String

appsettings.json:

{ "ConnectionStrings": { "BlazorChatDb": "Server=.;Database=BlazorChatDb;Trusted_Connection=true;TrustServerCertificate=true;" } }

3. Update Program.cs

builder.Services.AddPleromaPersistence(options =>
{
    options.UseSqlServer(builder.Configuration.GetConnectionString("BlazorChatDb"));
});

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

var dbConnectionString = builder.Configuration.GetConnectionString("BlazorChatDb") ?? throw new InvalidOperationException("ConnectionStrings:BlazorChatDb is missing.");

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

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

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

// Or, if using authentication: // 
// The hub runs anonymously by default. To require auth, map the hub directly:
 app.MapHub<BlazorChat.Server.Hubs.ChatHub>("/chathub").RequireAuthorization();`
 
## 🎯 Features

- **Persistent Messages** — survive server restarts
- **Emoji Reactions** — per-message reactions with summary aggregation
- **Message Editing & Deletion** — soft-delete with restore
- **Exportable SQL Scripts** — review and customize before deployment
- **Azure SQL Compatible** — works with SQL Server 2016+ and Azure SQL Database

## 📋 Database Schema

All objects live in the `chat` schema:

| Object | Type | Purpose |
|--------|------|---------|
| `chat.Messages` | Table | Message storage with thread, sender, edit/delete tracking |
| `chat.Reactions` | Table | Emoji reactions per message (Latin1_General_100_CI_AS_SC collation) |
| `chat.p_AddMessage` | Stored Proc | Insert a message |
| `chat.p_GetMessages` | Stored Proc | Retrieve messages by thread |
| `chat.p_EditMessage` | Stored Proc | Update message text |
| `chat.p_DeleteMessage` | Stored Proc | Soft-delete a message |
| `chat.p_RestoreMessage` | Stored Proc | Undo a soft-delete |
| `chat.p_ToggleReaction` | Stored Proc | Add/remove an emoji reaction |
| `chat.p_GetReactionSummary` | Stored Proc | Reaction summary by timestamp |
| `chat.p_GetReactionSummaryByMessageId` | Stored Proc | Reaction summary by message ID |
| `chat.p_GetReactionSummaries` | Stored Proc | Batch reaction summaries |

## 📦 Prerequisites

- SQL Server 2016+ or Azure SQL Database
- BlazorChat.Server license (30-day trial included)

## 📜 License

Same commercial license as BlazorChat.Server.

- [Purchase](https://loneworx.com/blazor-chat/pricing)

---

**Copyright (C) 2024-2026 LoneWorx LLC** — [loneworx.com](https://loneworx.com)
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.

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.3 31 3/13/2026
1.0.2 82 3/9/2026

v1.0.3:
- Fixed: README accuracy — removed non-existent features, corrected table list, updated Program.cs example

v1.0.2:
- Fixed: Emoji reactions replacing each other when multiple different emojis added to the same message
- Fixed: Emoji column collation — uses Latin1_General_100_CI_AS_SC so SQL Server distinguishes emoji code points
- Fixed: Split ToggleReactionAsync into separate DML and SELECT calls to work around ExecuteReaderAsync not reading result sets after INSERT/DELETE
- Added: New stored procedure p_GetReactionSummaryByMessageId for clean summary readback
- Breaking: Existing chat.Reactions table must be dropped and recreated to pick up the new collation (if in production)