Database Reference
In-Depth Information
Figure 5-26.
A model for projects, managers, and contractors
Start by adding a console application project to Visual Studio entitled
Recipe11
. 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:
Contractor
,
Manager
, and
Project
. Then copy the code from Listing 5-27
into the classes.
Listing 5-27.
Entity Classes
public class Contractor
{
public int ContracterID { get; set; }
public string Name { get; set; }
public int ProjectID { get; set; }
public virtual Project Project { get; set; }
}
public class Manager
{
public Manager()
{
Projects = new HashSet<Project>();
}
public int ManagerID { get; set; }
public string Name { get; set; }
public virtual ICollection<Project> Projects { get; set; }
}
public class Project
{
public Project()
{
Contractors = new HashSet<Contractor>();
}