| Department object | Hard Coded | EF-Core |
| DeptId | 1 | 1 |
| DeptName | Sales | Sales |
| Location | Mumbai | Mumbai |
| Employees | null | {Collection of Employees objects from this Dept} |
| Employee object | Hard Coded | EF-Core |
| Id | 1 | 1 |
| EmpCode | ABC001 | ABC001 |
| Name | Avinash Tauro | Avinash Tauro |
| [email protected] | [email protected] | |
| DateOfBirth | 17-08-1976 | 17-08-1976 |
| Salary | 100000 | 100000 |
| DepartmentRefId | 1 | 1 |
| Department | null | {Department object for DeptId = 1} |
| Active | TRUE | TRUE |
public class Department
{
[Key]
public int DeptId { get; set; }
[Required]
[StringLength(50)]
[Column(TypeName = "VARCHAR(50)")]
public string DeptName { get; set; }
[StringLength(50)]
[Column(TypeName = "VARCHAR(50)")]
public string Location { get; set; }
public ICollection<Employee> Employees { get; set; }
[Required]
[StringLength(7, MinimumLength = 7)]
[Column(TypeName = "CHAR(7)")]
[RegularExpression("^[A-Z]{3}[0-9]{4}$")]
public string EmpCode { get; set; }
[StringLength(100)]
[Column(TypeName = "VARCHAR(100)")]
public string Name { get; set; }
[ForeignKey("Department")]
public int DepartmentRefId { get; set; }
public Department Department { get; set; }
}