for a job application project, if jobseeker applies for a job what fields should necessary for an employer i am setting applications table for employes perspective to show applications to employer for a particular job. i am making table through code first approach,so accordingly
job id,emplyer id,jobseeker id,resume,applydate,status, this data i consider tobe necessary to hold in this table for that i use this code.
public class Application
{
[Key]
public int AppId { get; set; }
public DateTime ApplyDate { get; set; }
public int EmpId { get; set; }
public virtual Employer Employer { get; set; }
public int JobId { get; set; }
public virtual Jobs Job { get; set; }
public int CanId { get; set; }
public virtual Candidate Candidate { get; set; }
public byte Status { get; set; }
public ICollection Candidates { get; set; }
}is this approach OK or need some corrections.moreover how may i get list of applicants who applied for a specific job.will this code work for getting list of candidates

Sachin SinghRank #66 · 26.2K reputationPosted Jan 18, 2024, 10:33 AM EST
Instead of using
bytefor theStatusfield, consider using anenumpublic enum ApplicationStatus { Applied, UnderReview, Rejected, Accepted } public class Application { // ... other properties public ApplicationStatus Status { get; set; } }int jobId = 123; // Replace with the actual job ID var applicantsForJob = dbContext.Applications .Where(app => app.JobId == jobId) .Select(app => app.Candidate) .ToList();Jignesh KumarRank #91 · 22.9K reputationPosted Jan 18, 2024, 11:38 PM EST
Hello Umain,
Please do below class and DBContext for your code first approach,
Classes:
using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; public class Job { [Key] public int JobId { get; set; } // Other job-related properties public string JobTitle { get; set; } public string Description { get; set; } // Navigation property for applications related to this job public virtual ICollection Applications { get; set; } } public class Employer { [Key] public int EmployerId { get; set; } // Other employer-related properties public string CompanyName { get; set; } // Navigation property for applications submitted by this employer public virtual ICollection Applications { get; set; } } public class JobSeeker { [Key] public int JobSeekerId { get; set; } // Other job seeker-related properties public string FullName { get; set; } // Navigation property for applications submitted by this job seeker public virtual ICollection Applications { get; set; } } public class Application { [Key] public int ApplicationId { get; set; } // Foreign keys [ForeignKey("Job")] public int JobId { get; set; } [ForeignKey("Employer")] public int EmployerId { get; set; } [ForeignKey("JobSeeker")] public int JobSeekerId { get; set; } // Other application-related properties public string Resume { get; set; } [DataType(DataType.Date)] public DateTime ApplyDate { get; set; } // Possible statuses: Submitted, In Progress, Approved, Rejected, etc. public string Status { get; set; } // Navigation properties for related entities public virtual Job Job { get; set; } public virtual Employer Employer { get; set; } public virtual JobSeeker JobSeeker { get; set; } }DBContext :
public class YourDbContext : DbContext { public DbSet JobApplications { get; set; } public DbSet Jobs { get; set; } public DbSet Employers { get; set; } public DbSet JobSeekers { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { // Configure relationships here modelBuilder.Entity() .HasRequired(ja => ja.Job) .WithMany(j => j.Applications) .HasForeignKey(ja => ja.JobId); modelBuilder.Entity() .HasRequired(ja => ja.Employer) .WithMany() .HasForeignKey(ja => ja.EmployerId); modelBuilder.Entity() .HasRequired(ja => ja.JobSeeker) .WithMany() .HasForeignKey(ja => ja.JobSeekerId); } }Sam HobbsRank #107 · 20.5K reputationPosted Jan 18, 2024, 1:34 PM EST
I am not sure what the various fields are for. In my understanding, an applicant and a candidate are the same thing. Perhaps you could call your main table a positions tabel. That is one possibility but you can use whatever term is meaningful for you but I think your table here is not a table of applications. A position might have one and only one job and employer and an associated list of candidates. A candidate (applicant) might have an ApplyDate and fields such as phone number. A position might have a list of skills and an applicant might also have a list of skills. It is important to begin with a good database design, You can use GenMyModel to make an impressive database design if you want.
https://app.genmymodel.com
Personally what I do is to create a sample database then I use generate code for it. In ohter words, I use Database First. It is easier for me to understand.