Database Reference
In-Depth Information
public partial class Order
{
public Order()
{
this.OrderDetails = new HashSet<OrderDetail>();
}
public int OrderId { get; set; }
public int CustomerId { get; set; }
public System.DateTime OrderDate { get; set; }
public virtual Customer Customer { get; set; }
public virtual ICollection<OrderDetail> OrderDetails { get; set; }
}
public partial class OrderDetail
{
public int OrderId { get; set; }
public int ProductId { get; set; }
public decimal UnitPrice { get; set; }
public int Quantity { get; set; }
public virtual Order Order { get; set; }
public virtual Product Product { get; set; }
}
public partial class Product
{
public Product()
{
this.OrderDetails = new HashSet<OrderDetail>();
}
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
public virtual ICollection<OrderDetail> OrderDetails { get; set; }
}
Notice that there is no association from Product to OrderDetail, because we removed that navigation property
in the designer.
6.
To use POCO classes, Entity Framework also generated the class that is derived from
DbContext. This class will expose an ObjectSet<T> for each of the entities in our model.
The code in Listing 8-2 illustrates how we might define this class.
Listing 8-2. DbContext for Our Model Created While Generating an Entity Data Model
public partial class EFRecipesEntities : DbContext
{
public EFRecipesEntities()
: base("name=EFRecipesEntities")
{
}
 
Search WWH ::




Custom Search