Tutorials Entity Framework Core Tutorial
HRMS Database with EF Core
HRMS Database with EF Core: free step-by-step lesson with examples, common mistakes, and interview tips — part of Entity Framework Core Tutorial on Toolliyo Academy.
On this page
Entity Framework Core Tutorial · Lesson 95 of 100
HRMS Database with EF Core
Beginner ✓ → Intermediate ✓ → Advanced ✓ → Professional
Professional · 4 — Real projects · ~10 min · Module 10: Real-World Projects
What is this?
HRMS databases store employees, departments, leave requests, payroll periods, and attendance — EF models organizational hierarchy and approval workflows.
Why should you care?
ShopNest internal HR portal tracks 500 employees — EF Code First evolves schema as leave policy fields add.
See it live — copy this example
Paste into a .NET project with EF Core packages, then run with LocalDB/SQL Server (dotnet ef / dotnet run).
public class Employee { public int Id { get; set; } public string Code { get; set; } = ""; public int DepartmentId { get; set; } public Department Department { get; set; } = null!; }
public class LeaveRequest { public int Id { get; set; } public int EmployeeId { get; set; } public DateTime From { get; set; } public DateTime To { get; set; } public string Status { get; set; } = "Pending"; }
var pending = await db.LeaveRequests
.Include(l => l.Employee)
.Where(l => l.Status == "Pending")
.OrderBy(l => l.From)
.ToListAsync();
What happened?
- LeaveRequest FK to Employee.
- Include brings employee code for manager approval queue.
- Status filter shows pending approvals only.
Practice next
- Model Department with self-referencing manager optional.
- Add LeaveRequest status enum string or int.
- Seed departments and sample employees via HasData.
- Add Attendance table with composite EmployeeId+Date key.
- Group pending leave count by Department for dashboard.
Remember
HRMS links Employee, Department, LeaveRequest. Approval queue filters Pending status. Prefer soft delete on employee records.
ShopNest people ops
ShopNest HRMS LeaveRequest queue uses EF Include for manager self-service portal.
Outcome: Managers approve leave without IT running manual SQL reports.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!