BlueBeard.Database
0.1.0-ci.24
dotnet add package BlueBeard.Database --version 0.1.0-ci.24
NuGet\Install-Package BlueBeard.Database -Version 0.1.0-ci.24
<PackageReference Include="BlueBeard.Database" Version="0.1.0-ci.24" />
<PackageVersion Include="BlueBeard.Database" Version="0.1.0-ci.24" />
<PackageReference Include="BlueBeard.Database" />
paket add BlueBeard.Database --version 0.1.0-ci.24
#r "nuget: BlueBeard.Database, 0.1.0-ci.24"
#:package BlueBeard.Database@0.1.0-ci.24
#addin nuget:?package=BlueBeard.Database&version=0.1.0-ci.24&prerelease
#tool nuget:?package=BlueBeard.Database&version=0.1.0-ci.24&prerelease
BlueBeard.Database
A lightweight MySQL ORM for Unturned plugins. Define entity classes with attributes, and use LINQ-style expressions for queries -- the ORM translates them to SQL automatically.
Installation
Add a project reference:
<ProjectReference Include="..\BlueBeard.Database\BlueBeard.Database.csproj" />
Requires MySqlConnector (included in the packages folder).
Setup
using BlueBeard.Core.Configs;
using BlueBeard.Database;
// In your plugin's Load():
var configManager = new ConfigManager();
configManager.Initialize(Directory);
configManager.LoadConfig<DatabaseConfig>();
var db = new DatabaseManager();
db.Initialize(configManager);
db.RegisterEntity<Player>();
db.RegisterEntity<Faction>();
db.Load(); // connects and syncs schema
DatabaseConfig stores connection details (host, port, database, username, password) and is created automatically with defaults on first run.
Defining Entities
using BlueBeard.Database.Attributes;
[Table("factions")]
public class Faction
{
[PrimaryKey] [AutoIncrement]
[Column("id")]
public int Id { get; set; }
[Column("name")]
public string Name { get; set; }
[Column("leader_steam_id")]
public ulong LeaderSteamId { get; set; }
[Column("created_at")]
public DateTime CreatedAt { get; set; }
}
Attributes
| Attribute | Target | Description |
|---|---|---|
[Table("name")] |
Class | Maps the class to a MySQL table. Defaults to the class name if omitted. |
[Column("name")] |
Property | Maps the property to a column. Defaults to the property name if omitted. |
[PrimaryKey] |
Property | Marks the primary key column. |
[AutoIncrement] |
Property | Marks the column as AUTO_INCREMENT. Value is set after insert. |
Supported Types
int, long, ulong, string (VARCHAR 255), bool, float, double, DateTime, and any enum (stored as INT).
Schema Sync
Tables are created automatically via CREATE TABLE IF NOT EXISTS when Load() is called. No migrations needed for new tables.
CRUD Operations
All operations are async and should be called from a background thread (use ThreadHelper.RunAsynchronously):
Query All
var factions = await db.Table<Faction>().QueryAsync();
Query with Filter
// LINQ expression is translated to SQL WHERE clause:
var results = await db.Table<Faction>().Where(f => f.LeaderSteamId == steamId);
First or Default
var faction = await db.Table<Faction>().FirstOrDefaultAsync(f => f.Name == "Wolves");
Insert
var faction = new Faction { Name = "Wolves", LeaderSteamId = 76561198012345678 };
await db.Table<Faction>().InsertAsync(faction);
// faction.Id is now set (auto-increment)
Update
faction.Name = "Alpha Wolves";
await db.Table<Faction>().UpdateAsync(faction);
Delete
// By entity:
await db.Table<Faction>().DeleteAsync(faction);
// By predicate:
await db.Table<Faction>().DeleteAsync(f => f.Id == 5);
Expression Support
The Where and FirstOrDefaultAsync methods accept C# lambda expressions that are translated to SQL:
// Equality
f => f.Name == "Wolves" // WHERE `name` = @p0
// Comparison
f => f.Id > 10 // WHERE `id` > @p0
// Compound
f => f.Id > 5 && f.Name != null // WHERE (`id` > @p0 AND `name` IS NOT NULL)
// Or
f => f.Id == 1 || f.Id == 2 // WHERE (`id` = @p0 OR `id` = @p1)
// Variable capture
var name = "Wolves";
f => f.Name == name // WHERE `name` = @p0 (parameterized)
Full Example
ThreadHelper.RunAsynchronously(async () =>
{
var faction = await db.Table<Faction>()
.FirstOrDefaultAsync(f => f.LeaderSteamId == player.CSteamID.m_SteamID);
ThreadHelper.RunSynchronously(() =>
{
if (faction != null)
UnturnedChat.Say(player, $"Your faction: {faction.Name}");
else
UnturnedChat.Say(player, "You don't have a faction.");
});
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net481 is compatible. |
-
.NETFramework 4.8.1
- BlueBeard.Core (>= 0.1.0-ci.24)
- MySqlConnector (>= 2.5.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on BlueBeard.Database:
| Package | Downloads |
|---|---|
|
BlueBeard.Zones
Advanced zone management for Unturned. Trigger colliders, persistent storage, 26 enforcement flags, block lists, and CLI administration. |
|
|
BlueBeard.Cooldowns
Centralised cooldown/timer tracking for Unturned plugins. In-memory or database-backed persistence, clock injection for tests. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-ci.24 | 91 | 7/4/2026 |
| 0.1.0-ci.23 | 100 | 6/25/2026 |
| 0.1.0-ci.22 | 123 | 5/8/2026 |
| 0.1.0-ci.19 | 82 | 5/7/2026 |
| 0.1.0-ci.18 | 66 | 5/7/2026 |
| 0.1.0-ci.17 | 92 | 5/3/2026 |
| 0.1.0-ci.16 | 77 | 5/3/2026 |
| 0.1.0-ci.15 | 84 | 4/13/2026 |
| 0.1.0-ci.14 | 77 | 4/12/2026 |
| 0.1.0-ci.13 | 72 | 4/12/2026 |
| 0.1.0-ci.12 | 79 | 4/12/2026 |
| 0.1.0-ci.11 | 74 | 4/12/2026 |
| 0.1.0-ci.10 | 80 | 4/11/2026 |
| 0.1.0-ci.9 | 76 | 4/7/2026 |
| 0.1.0-ci.8 | 71 | 4/7/2026 |
| 0.1.0-ci.7 | 70 | 4/7/2026 |
| 0.1.0-ci.6 | 83 | 3/14/2026 |
| 0.1.0-ci.5 | 127 | 2/22/2026 |