A clean, interactive C#/.NET console application for managing Students, Instructors, Courses, Categories, and Enrollments with Entity Framework Core (SQL Server LocalDB). It demonstrates real-world CRUD, 1-N and N-N relationships (via a join entity), and LINQ-based reports โ all through a structured, friendly terminal UI.
This project is a modular console app that simulates a mini learning platform back office. It covers the full flow:
- Create Categories โ add Instructors โ add Courses โ manage Students โ Enroll students โ generate Reports โ with consistent menus, validation helpers, and a reusable reporting printer.
- โ CRUD for Students, Instructors, Categories, and Courses
- ๐งพ Enroll students into courses (prevents duplicate enrollments)
- ๐ Reports:
- Courses with their instructors
- Enrollment count per course
- Students with their courses
- Course (by ID) with enrolled students
- Top 3 courses by enrollments
- ๐ Query helper: Get courses under a specific price (service-level)
- ๐งฑ Separation of concerns:
Models,Services,Screens,Helpers,Data - ๐งฐ Generic base service for common CRUD with EF Core
- ๐งฏ Graceful console messages + minimal error handling on
SaveChanges()
CourseManagementSystem/
โโโ Data/
โ โโโ AppDbContext.cs # EF Core DbContext + relationships
โโโ Helpers/
โ โโโ ConsoleUIHelper.cs # Boxed menus, prompts
โ โโโ InputHelper.cs # Input validation (int/decimal/string)
โโโ Migrations/ # EF Core migrations + snapshot
โโโ Models/
โ โโโ CategoryModel.cs
โ โโโ CourseModel.cs
โ โโโ EnrollmentModel.cs
โ โโโ InstructorModel.cs
โ โโโ StudentModel.cs
โโโ Screens/
โ โโโ Category/
โ โ โโโ AddCategoryScreen.cs
โ โ โโโ CategoryMenuScreen.cs
โ โ โโโ ViewCategoriesScreen.cs
โ โโโ Course/
โ โ โโโ AddCourseScreen.cs
โ โ โโโ CourseMenuScreen.cs
โ โ โโโ UpdateCourseScreen.cs
โ โ โโโ ViewCourseScreen.cs
โ โโโ Instructor/
โ โ โโโ AddInstructorScreen.cs
โ โ โโโ InstructorMenuScreen.cs
โ โ โโโ ViewInstructorsScreen.cs
โ โโโ Reports/
โ โ โโโ ReportPrinter.cs
โ โ โโโ ReportsMenuScreen.cs
โ โ โโโ ReportsRenderingMethodsScreen.cs
โ โโโ Student/
โ โโโ AddStudentScreen.cs
โ โโโ DeleteStudentScreen.cs
โ โโโ EnrollStudentScreen.cs
โ โโโ StudentMenuScreen.cs
โ โโโ UpdateStudentScreen.cs
โ โโโ ViewStudentsScreen.cs
โโโ Services/
โ โโโ BaseService.cs
โ โโโ CategoryService.cs
โ โโโ CourseService.cs
โ โโโ EnrollmentService.cs
โ โโโ InstructorService.cs
โ โโโ ReportService.cs
โ โโโ StudentService.cs
โโโ Program.cs
Category (1) โโโ (โ) Course (โ) โโโ (โ) Student via Enrollment
โ
โโโ (1) Instructor
- Many-to-Many between
StudentandCourseinplemented via Enrollment join table - One-to-Many:
Instructor->Courses,Category->Courses - Relationships configured in
AppDbContext.OnModelCreating(โฆ).
- StudentModel
int Id,string FullName,string EmailICollection<EnrollmentModel> Enrollments
- InstructorModel
int Id,string FullName,string EmailICollection<CourseModel> Courses
- CategoryModel
int Id,string NameICollection<CourseModel> Courses
- CourseModel
int Id,string Title,string Description,decimal Priceint InstructorId,InstructorModel Instructorint CategoryId,CategoryModel CategoryICollection<EnrollmentModel> Enrollments
- EnrollmentModel
int Idint StudentId,StudentModel Studentint CourseId,CourseModel Course
- BaseService
Add(T entity),Update(T entity),T? GetById(int id),List<T> GetAll()
- StudentService : BaseService
Delete(int id)โ removes student + their enrollmentsGetStudentsWithoutCourses()
- InstructorService : BaseService
- CategoryService : BaseService
- CourseService : BaseService
GetCoursesUnderPrice(decimal maxPrice)โ{ Title, Price }
- EnrollmentService : BaseService
- ReportService
GetCoursesWithInstructors()โ{ Title, InstructorName }GetEnrollmentsCount()โ{ Title, StudentCount }GetStudentsWithCourses()โStudentModel+Enrollments.CourseGetCourseWithStudents(int id)โCourseModel+Enrollments.StudentGetTop3CoursesByEnrollments()โ{ Title, Count }
[MAIN MENU]
1) Student Menu
2) Category & Instructor Management
3) Course Menu
4) Reports Menu
5) Exit
Recommended workflow
- Add Category โ 2. Add Instructor โ 3. Add Course
- Add Student โ 5. Enroll Student in Course โ 6. Run Reports
# 1) Clone
git clone https
cd CourseManagementSystem
# 2) Ensure .NET SDK & EF Tools
dotnet --version
dotnet tool install --global dotnet-ef
# 3) Apply EF Core migrations (SQL Server LocalDB)
dotnet ef database update
# 4) Run
dotnet runConnection string lives in
AppDbContext.OnConfiguring(LocalDB):
Server=(localdb)\mssqllocaldb;Database=CourseManagementSystem;Trusted_Connection=True;
You can adapt it for a full SQL Server instance if needed.
- ๐งฑ C# .NET (Console App)
- ๐๏ธ Entity Framework Core (with Migrations)
- ๐ SQL Server LocalDB
- ๐งฎ LINQ queries +
Include/ThenInclude - ๐ฅ๏ธ Console UI with boxed menus & validated input
- ๐งฉ Clean separation across Data/Models/Services/Screens/Helpers
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MAIN MENU โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ[1] Student Menu โ
โ[2] Category & Instructor Management โ
โ[3] Course Menu โ
โ[4] Reports Menu โ
โ[5] Exit โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
-> Select an option:
Sample โView Studentsโ table
โโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ID โ Full Name โ Email โ
โโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 1 โ Mohamed Ahmed โ mohamed@gmail.com โ
โ 2 โ Maria Amr โ maria@gmail.com โ
โโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Report: Top 3 Courses by Enrollments
TOP 3 COURSES BY ENROLLMENTS
---------------------------------------------
Course Title | Enrollments
---------------------------------------------
C# Fundamentals | 12
SQL for Beginners | 9
ASP.NET Core Essentials | 7
---------------------------------------------
# Add a Category
[Category Menu] -> Add Category
-> Enter Category Name: "Programming"
# Add an Instructor
[Instructor Menu] -> Add Instructor
-> Full Name: "Dr. Mostafa Saad"
-> Email: "mostafasaad@gamil.com"
# Add a Course
[Course Menu] -> Add Course
-> Title: "C++ Fundamentals"
-> Description: "Intro to C++"
-> Price: 1000.00
-> Instructor ID: 1
-> Category ID: 1
# Add Student
[Student Menu] -> Add Student
-> Full Name: "Mohamed Ahmed"
-> Email: "mohamed@gmail.com"
# Enroll Student
[Student Menu] -> Enroll Student in Course
-> Student ID: 1
-> Course ID: 1
# Reports
[Reports Menu] -> Enrollment count per course
- Modeling 1โN and NโN relationships in EF Core with a join entity
- writing espressive LINQ queries with
Include/ThenIncludefor eager loading - Building a generic service layer to reduce CRUD relationships
- Designing console-first UX (clear menus, aligend tables, helpful prompts)
- Organizing a solution for maintainability (Data/Models/Services/Screens/Helpers)
- Using migrations and LocalDB connection for quick persistence
- โ Use the โcourses under priceโ query in the UI (currently implemented at service level)
- ๐ Search & filters (by name, price range, category) + pagination in listings
- ๐งน Stronger input validation, domain rules, and centralized error handling
- ๐งฑ Introduce DTOs/mappers to separate UI from EF entities
- ๐งช Unit tests for services and helpers
- ๐งพ Seed data for quick demos
- โ๏ธ Move connection string to configuration (appsettings) and support multiple environments
- ๐ค Export reports to CSV/JSON
- ๐งโ๐ป Consider moving to a web UI (ASP.NET Core MVC/Minimal APIs) later
๐ Task Outline (Google Drive)
๐ธ Archived Copy at submission time (Google Drive)
Made with โค๏ธ by Kenzy Ragab
Feel free to fork, use, or contribute to this project!