Database Reference
In-Depth Information
Figure 5-23. A a model with an employee, her department, and the department's company
Start by adding a console application project to Visual Studio entitled Recipe8 . Be certain to reference the Entity
Framework 6 libraries. Leveraging the NuGet Package Manager does this best. Right-click on Reference, and select
Manage NuGet Packages. From the Online tab, locate and install the Entity Framework 6 package. Doing so will
download, install, and configure the Entity Framework 6 libraries in your project.
Next we create three entity objects: Company , Department , and Employee , and copy the code from Listing 5-18 into
three classes.
Listing 5-18. Entity Classes
public class Company
{
public Company()
{
Departments = new HashSet<Department>();
}
public int CompanyId { get; set; }
public string Name { get; set; }
public virtual ICollection<Department> Departments { get; set; }
}
public class Department
{
public Department()
{
Employees = new HashSet<Employee>();
}
public int DepartmentId { get; set; }
public string Name { get; set; }
public int CompanyId { get; set; }
public virtual Company Company { get; set; }
public virtual ICollection<Employee> Employees { get; set; }
}
 
Search WWH ::




Custom Search