Three-layer .NET 8 Windows Forms desktop application with Entity Framework Core Code First and SQL Server LocalDB.
ComputerGamesORM.WinForms- primary presentation layer. Contains the polished WinForms CRUD UI, DI startup, LocalDB configuration, validation feedback, confirmation dialogs, and async event handlers.ComputerGamesORM.Business- business logic layer. Contains service contracts, DTOs, edit models, validation rules, and CRUD operations.ComputerGamesORM.Data- data access layer. Contains EF Core entities, configurations, DbContext, repository implementation, migrations, design-time context factory, and database initializer.ComputerGamesORM.Presentation- legacy console presentation kept for reference and compatibility.ComputerGamesORM.Tests- NUnit tests for service-level CRUD and validation behavior using SQLite in-memory relational storage.
Code First creates database ComputerGamesORM with two related tables:
GamesIdprimary keyNamerequired, max length 200, unique index
GameDescriptionsIdprimary keyDescriptionrequired, max length 2000GameIdrequired foreign key toGames.Id
The relationship is one-to-one. Deleting a game cascades to its description.
Main packages used:
Microsoft.EntityFrameworkCoreMicrosoft.EntityFrameworkCore.SqlServerMicrosoft.EntityFrameworkCore.DesignMicrosoft.EntityFrameworkCore.ToolsMicrosoft.Extensions.Configuration.JsonMicrosoft.Extensions.DependencyInjectionMicrosoft.Extensions.Logging.AbstractionsMicrosoft.EntityFrameworkCore.Sqlitefor relational testsNUnit,NUnit3TestAdapter,Microsoft.NET.Test.Sdk
- Modern dark UI with responsive table/details layout
- Search by ID, game name, or description
- Customized
DataGridView - Details/edit panel
- Add, edit, delete, save, cancel, refresh workflows
- Input validation with
ErrorProvider - Duplicate name prevention in BLL
- Delete confirmation dialog
- Status notifications
- Startup database migration and sample seed data
Restore dependencies:
dotnet restoreRestore EF Core CLI tool:
dotnet tool restoreBuild and test:
dotnet build
dotnet testRun the Windows Forms app:
dotnet run --project src/ComputerGamesORM.WinFormsThe WinForms app uses LocalDB by default:
Server=(localdb)\MSSQLLocalDB;Database=ComputerGamesORM;Trusted_Connection=True;TrustServerCertificate=True;MultipleActiveResultSets=true
The database is migrated automatically on startup.
The Docker target is intentionally limited to the legacy console project. The production WinForms UI is an interactive Windows desktop application and should be launched on Windows.
Add a migration:
dotnet ef migrations add InitialCreate --project src/ComputerGamesORM.Data --startup-project src/ComputerGamesORM.WinForms --context ComputerGamesContext --output-dir MigrationsApply migrations manually:
dotnet ef database update --project src/ComputerGamesORM.Data --startup-project src/ComputerGamesORM.WinForms --context ComputerGamesContext- Add pagination for very large game catalogs.
- Add richer metadata such as genre, platform, release year, and publisher.
- Add integration tests against SQL Server LocalDB in addition to the SQLite relational tests.
- Add import/export for CSV or Excel catalog management.