- Retrieve database credentials
- Install the Bunny.LibSQL.Client package
- Connect to a remote Bunny Database
- Define models and run migrations
- Execute queries using LINQ
While foundational ORM and querying features are available, several
enhancements are still in progress. You can report issues, contribute, or
learn more on GitHub.
Quickstart
1
Retrieve database credentials
You will need an existing database to continue. If you don’t have one, create one.Navigate to Dashboard > Edge Platform > Database > [Select Database] > Access to find your database URL and generate an access token.
You should store these as environment variables to keep them secure.
2
Install Bunny.LibSQL.Client
Install the package via NuGet:
3
Define your database
Create a database context class that inherits from
LibSqlDbContext:4
Define your models
Create model classes with attributes to define the table structure:
5
Initialize and migrate
Create an instance of your database context and apply migrations:
6
Execute a query
You can query your database using LINQ:
Managing Records
Insert
Insert records usingInsertAsync:
Update
Update records usingUpdateAsync:
Delete
Delete records usingDeleteAsync:
Querying with LINQ
Basic Query
Eager Loading with Include
Load related entities usingInclude():
Aggregates
Perform aggregate queries withCountAsync() and SumAsync():
Transactions
Use transactions to group multiple operations together:Direct SQL Queries
For raw SQL access, use the underlying client directly.Run a command
Get a scalar value
Model Attributes
| Attribute | Description |
|---|---|
Table | Specifies a custom table name for the entity. If omitted, class name is used. |
Key | Marks the property as the primary key of the table. |
Index | Creates an index on the annotated property for faster lookups. |
ForeignKey | Defines a relationship to another table by specifying the foreign key property. |
AutoInclude | Enables eager loading of the related property automatically during queries. |
Unique | Marks the field with the UNIQUE constraint, ensuring a unique value in every row. |
ManyToMany | Defines a many-to-many relationship through a join table. |
Supported Data Types
| C# Type | Description | SQLite Type |
|---|---|---|
string | Textual data | TEXT |
int | 32-bit integer | INTEGER |
long | 64-bit integer | INTEGER |
double | Double-precision floating point | REAL |
float | Single-precision floating point | REAL |
decimal | Decimal number | REAL |
DateTime | Date and time | INTEGER (UNIX timestamp) |
bool | Boolean value | INTEGER (0 or 1) |
byte[] | Binary data | BLOB |
F32Blob | Vector F32 blob (AI embeddings) | F32_BLOB |
Nullable variants (e.g.,
int?, bool?) are also supported and will map to
nullable columns.