This guide explains how to set up SQLite for the Dividex budgeting application.
You need the .NET 10.0 SDK installed with the MAUI workload. If you haven't already:
On macOS:
# Install .NET 10.0 SDK (if not already installed)
# Download from: https://dotnet.microsoft.com/download/dotnet/10.0
# Install MAUI workload
dotnet workload install mauiOn Windows:
# Install .NET 10.0 SDK (if not already installed)
# Download from: https://dotnet.microsoft.com/download/dotnet/10.0
# Install MAUI workload
dotnet workload install mauiFor macOS (Mac Catalyst):
- macOS 12.0 or later
- Xcode 15.0 or later (for Mac Catalyst development)
- Command Line Tools for Xcode
For iOS:
- macOS 12.0 or later
- Xcode 15.0 or later
- iOS 15.0 or later device/simulator
For Android:
- Android SDK (installed via Visual Studio or Android Studio)
- Android API 24 or later
For Windows:
- Windows 10 version 17763.0 or later
- Visual Studio 2022 with .NET MAUI workload
Good news: You don't need to install SQLite separately!
SQLite is automatically included when you install the NuGet packages. The Entity Framework Core SQLite provider handles everything for you.
After cloning or downloading the project, restore the NuGet packages:
cd /path/to/dividex
dotnet restoreThis will download:
Microsoft.EntityFrameworkCore.Sqlite(version 10.0.0)Microsoft.EntityFrameworkCore.Tools(version 10.0.0)
Build the project to ensure everything compiles correctly:
dotnet buildThe database will be automatically created on first run. Run the application:
For Mac Catalyst:
dotnet run -f net10.0-maccatalystFor iOS Simulator:
dotnet run -f net10.0-iosFor Android:
dotnet run -f net10.0-androidFor Windows:
dotnet run -f net10.0-windows10.0.19041.0The SQLite database file (dividex.db) is automatically created in the application's local data folder:
- macOS (Mac Catalyst):
~/Library/Application Support/com.companyname.dividex/dividex.db - iOS: App's Documents directory (sandboxed)
- Android: App's data directory (sandboxed)
- Windows:
%LOCALAPPDATA%\dividex\dividex.db
You typically don't need to access this file directly, but it's useful to know where it's stored for backup purposes.
-
First Run: When you first launch the app, the database is automatically created using
EnsureCreated(). This happens inMauiProgram.csduring app startup. -
Data Persistence: All budget data (salary, categories, subcategories, fixed costs, variable costs) is stored in the SQLite database.
-
No Manual Setup Required: The database schema is defined in
Data/BudgetDbContext.csand is automatically applied on first run.
Solution: Make sure you've restored NuGet packages:
dotnet restoreSolution: Check that the application has write permissions to the local application data folder. This is usually automatic, but on some systems you may need to grant permissions.
Solution: If you need to create migrations (usually not required), install the EF Core tools:
dotnet tool install --global dotnet-efSolution:
- Check that the database file exists in the location mentioned above
- Verify that
EnsureCreated()is being called (checkMauiProgram.cs) - Ensure you're using the
BudgetServiceorBudgetDbContextcorrectly in your components
In your Razor components, inject the BudgetService:
@inject dividex.Services.BudgetService BudgetService
@code {
protected override async Task OnInitializedAsync()
{
var budget = await BudgetService.GetLatestBudgetAsync();
// Use the budget data...
}
}@inject dividex.Data.BudgetDbContext DbContext
@code {
private async Task LoadData()
{
var budgets = await DbContext.Budgets
.Include(b => b.Categories)
.ToListAsync();
}
}The database contains the following tables:
Budgets- Stores budget information (monthly salary, timestamps)Categories- Budget categories (Needs, Wants, Savings, etc.)Subcategories- Subcategories within categoriesFixedCosts- Fixed cost items (can belong to category or subcategory)VariableCosts- Variable cost items (can belong to category or subcategory)
All relationships are configured with cascade delete, so deleting a budget will remove all associated data.
If you encounter any issues:
- Check that all prerequisites are installed
- Run
dotnet restoreanddotnet build - Verify the database file is being created in the expected location
- Check the application logs for error messages