Persistord.Core
1.0.0-beta2
dotnet add package Persistord.Core --version 1.0.0-beta2
NuGet\Install-Package Persistord.Core -Version 1.0.0-beta2
<PackageReference Include="Persistord.Core" Version="1.0.0-beta2" />
<PackageVersion Include="Persistord.Core" Version="1.0.0-beta2" />
<PackageReference Include="Persistord.Core" />
paket add Persistord.Core --version 1.0.0-beta2
#r "nuget: Persistord.Core, 1.0.0-beta2"
#:package Persistord.Core@1.0.0-beta2
#addin nuget:?package=Persistord.Core&version=1.0.0-beta2&prerelease
#tool nuget:?package=Persistord.Core&version=1.0.0-beta2&prerelease
Persistord.Core
<div align="center">
← Persistord docs · Documentation site
</div>
Foundation package for Persistord, a provider-agnostic, Discord-library-agnostic persistence layer for Discord bots built on EF Core 10.
Persistord.Core ships:
- Snowflake conversion — Discord ids are
ulong; relational providers store signedlong.UlongToLongConverter/NullableUlongToLongConverterperform a bit-faithfuluncheckedround-trip, so every value (including ids with the high bit set) survives storage exactly. The conversion is registered globally inDiscordDbContext.ConfigureConventions, so you never annotate individual ids. DiscordDbContext— an abstract base context that maps the core skeleton entities (GuildEntity,ChannelEntity,UserEntity,MemberEntity,RoleEntity) and applies the snowflake convention. Inherit it, add the moduleDbSets you want, and apply module configurations inOnModelCreating.ApplyCoreConfiguration()— aModelBuilderextension that wires the core entity configurations.DiscordDbContextcalls it for you.
Provider-agnostic by design
The library never selects a database provider. It defines the model only. You choose the provider in your own composition root:
services.AddDbContextFactory<MyBotContext>(o => o.UseNpgsql(connectionString));
// or .UseSqlite(...), .UseSqlServer(...), etc.
Context lifetime
A Discord bot is long-lived and highly concurrent. Do not hold a single
DbContext for the bot's lifetime — its change tracker grows unbounded and it is
not thread-safe. Use IDbContextFactory<T> and create a short-lived context per
unit of work (per gateway event, per command):
await using var db = await factory.CreateDbContextAsync();
db.Guilds.Add(new GuildEntity { Id = guildId, Name = name, OwnerId = ownerId });
await db.SaveChangesAsync();
Snowflake storage note
Snowflakes are stored as long. Discord snowflakes stay below long.MaxValue
until roughly the year 2084, so signed storage is safe; the converter is
nevertheless bit-faithful and would round-trip even past that point.
License
MIT
| 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
- Microsoft.EntityFrameworkCore (>= 10.0.0 && < 11.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.0 && < 11.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Persistord.Core:
| Package | Downloads |
|---|---|
|
Persistord
Meta package that bundles the library-neutral Persistord stack — Core, Messages, and History — in a single reference. |
|
|
Persistord.Messages
Message persistence module for Persistord: MessageEntity with soft-delete, owned Embed model, relational attachments and reactions. |
|
|
Persistord.Adapters.DiscordNet
Discord.Net adapter for Persistord: extension methods mapping Discord.Net interface types to Persistord entities. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-beta2 | 198 | 7/20/2026 |
| 1.0.0-beta.1 | 244 | 6/14/2026 |