Database Reference
In-Depth Information
Listing 13-6. The Painting Entity Object
public class Company
{
public Company()
{
Doctors = new HashSet<Doctor>();
}
public int CompanyId { get; set; }
public string Name { get; set; }
public virtual ICollection<Doctor> Doctors { get; set; }
}
public class Doctor
{
public Doctor()
{
Appointments = new HashSet<Appointment>();
}
public int DoctorId { get; set; }
public string Name { get; set; }
public int CompanyId { get; set; }
public virtual ICollection<Appointment> Appointments { get; set; }
public virtual Company Company { get; set; }
}
public class Appointment
{
public int AppointmentId { get; set; }
public System.DateTime AppointmentDate { get; set; }
public string Patient { get; set; }
public int DoctorId { get; set; }
public virtual Doctor Doctor { get; set; }
}
Next, in Listing 13-7, we create the DbContext object, which is our gateway into Entity Framework functionality
when leveraging the Code-First approach.
Listing 13-7. DbContext Object
public class Recipe3Context : DbContext
{
public Recipe3Context()
: base("Recipe3ConnectionString")
{
// Disable Entity Framework Model Compatibility
Database.SetInitializer<Recipe3Context>(null);
}
Search WWH ::




Custom Search