SLVZ.Db 1.14.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global SLVZ.Db --version 1.14.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local SLVZ.Db --version 1.14.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=SLVZ.Db&version=1.14.0
                    
nuke :add-package SLVZ.Db --version 1.14.0
                    

πŸ“¦ SLVZ Db, Simple Local File Database for C#

A lightweight, dependency-free library for storing and retrieving data locally in a file.
This works like a very simplified ORM (similar to EF Core) but stores data in a plain text file β€” perfect for small projects, configs, or apps that don’t require a real database.


Features

  • Store and retrieve data without an external database
  • Supports primitive data types (int, string, bool, double, enum, ...)
  • Full CRUD operations (Append, Get, Update, Remove)
  • Data stored in a human-readable plain text format
  • Supports multiple models with separate database classes

How to Use

1. Create Your Data Model

enum Role
{
    Admin,
    User
}

class myModel
{
    public int ID { get; set; }
    public string Name { get; set; }
    public Role Role { get; set; }
    public double Grade { get; set; }
    public bool IsActive { get; set; }
}


2. Create Your Database Context

class myDB : DbContext<myModel>
{
    public override void Configuration()
    {
        SetConfig($"{Environment.CurrentDirectory}/slvz.db", "ID", "AES_KEY");
        // First argument: Database file full path
        // Second argument: Property name to be used as the unique key
        // Third argument: This is optional, If you want your database be encrypted, add AES_KEY to the third argument
    }
}



3. Example Usage

var db = new myDB();

// Add 3 users
await db.Append(new myModel
{
    ID = 1,
    Name = "Ashkan",
    Grade = 19.234,
    IsActive = true,
    Role = Role.Admin
});
await db.Append(new myModel
{
    ID = 2,
    Name = "Arash",
    Grade = 21.992,
    IsActive = true,
    Role = Role.User
});
await db.Append(new myModel
{
    ID = 3,
    Name = "Baran",
    Grade = 18.224452,
    IsActive = false,
    Role = Role.User
});

// Get all models
var models = await db.Get();

// Modify one model
models.Find(x => x.ID == 3).IsActive = true;

// Update it in the database
await db.Update(models.Find(x => x.ID == 3));

// Delete a model
// await db.Remove(3);

// Get a single model by ID
var model = await db.Get(3);

Console.WriteLine("Done");



API Reference

Append(TModel model)

Adds a single model to the database file.

  • Parameters:
    model β€” An instance of your model. Must match the configured model type.

Append(List<TModel> models)

Adds multiple models to the database at once.

  • Parameters:
    models β€” A list of model instances. All must match the configured model type.

List<TModel> Get()

Retrieves all models stored in the database.

  • Returns:
    A list of all models. Returns an empty list if no data file exists.

TModel Get(T id)

Retrieves a single model by its key property.

  • Parameters:
    key β€” The value of the key property to search for.

  • Returns:
    The model matching the key, or a new default instance if not found.


Update(TModel model)

Updates an existing model in the database.

  • Parameters:
    model β€” The updated model instance. The key property must match an existing entry.

AvailablePrimaryKey(List<T> recordKeys)

Return the first available primary key from database. You can send it a list if id's and it will return you the first ID that hasn't used


Remove(T id)

Deletes a model from the database by its key.

  • Parameters:
    key β€” The key value of the model to delete.

πŸ‘¨β€πŸ’» Author: SLVZ

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

This package has no dependencies.

Version Downloads Last Updated
1.23.0 101 5/31/2026
1.21.0 124 2/6/2026
1.19.0 122 12/30/2025
1.18.0 177 12/26/2025
1.17.0 190 12/26/2025
1.16.0 207 12/25/2025
1.15.0 145 12/12/2025
1.14.0 170 11/15/2025
1.13.0 255 11/14/2025
1.0.24 101 6/21/2026