This application now uses SQLite for data persistence. The database is automatically created on application startup.
Microsoft.EntityFrameworkCore.Sqlite(9.0.0)Microsoft.EntityFrameworkCore.Design(9.0.0)
The SQLite database file is created as fc26competition.db in the project root directory.
Located in appsettings.json:
"ConnectionStrings": {
"DefaultConnection": "Data Source=fc26competition.db"
}-
Restore NuGet packages:
dotnet restore
-
Run the application:
dotnet run
The database will be automatically created on the first run using EnsureCreatedAsync().
- All teams, matches, and results are now saved to the SQLite database
- Data persists between application restarts
- The database file (
fc26competition.db) is excluded from git via.gitignore
Id(Guid) - Primary KeyTeamName(nvarchar(100))Player1Name(nvarchar(100))Player2Name(nvarchar(100))ClubCountry(nvarchar(100))Played(int)Won(int)Drawn(int)Lost(int)GoalsFor(int)GoalsAgainst(int)
Id(Guid) - Primary KeyHomeTeamId(Guid) - Foreign Key to TeamsAwayTeamId(Guid) - Foreign Key to TeamsHomeScore(int, nullable)AwayScore(int, nullable)PlayedDate(datetime, nullable)Phase(int) - Enum: MainCompetition, ChampionsLeague, EuropaLeagueLeagueType(int, nullable) - Enum: ChampionsLeague, EuropaLeague
If you want to use EF Core Migrations instead of EnsureCreated():
-
Install the EF Core tools:
dotnet tool install --global dotnet-ef
-
Create initial migration:
dotnet ef migrations add InitialCreate
-
Apply migration:
dotnet ef database update
-
Update
Program.csto use migrations instead ofEnsureCreatedAsync():// Replace this line: await context.Database.EnsureCreatedAsync(); // With: await context.Database.MigrateAsync();
To start fresh (delete all data):
- Stop the application
- Delete the
fc26competition.dbfile - Restart the application - a new empty database will be created
If you get a "database is locked" error:
- Make sure only one instance of the application is running
- Close any SQLite browser tools that might have the database open
dotnet clean
dotnet restore
dotnet buildCompetitionServicenow usesIDbContextFactory<FC26CompetitionContext>- All methods are now async (suffix with
Async) - Uses scoped DbContext instances for each operation
- All Blazor pages updated to use async methods (
OnInitializedAsync, etc.) - Button click handlers call async methods
- Proper disposal of event handlers
- ✅ Data persists between sessions
- ✅ Supports concurrent access with DbContext factory
- ✅ Clean architecture with separation of concerns
- ✅ Easy to backup (just copy the .db file)
- ✅ No external database server required