Databases Reference
In-Depth Information
Supplier required for each Product, the multiplicity on the Supplier end of the association
would have been 1 instead.
FIGURE 2.7
Association between entities.
In addition to the associations, the Update Wizard also adds
navigation
properties to the
entities such as the
Supplier
property in the Product entity. Unlike the underlying
scalar
property
SupplierID
, which only stores a key value, the
Supplier
property returns an
instance of the Supplier entity it represents. On the opposite end of this association, the
Supplier class has a Products navigation property that returns an
EntityCollection
of
Product instances associated with a particular Supplier. Here is how the generated code
looks if you take a look at the
NorthwindEntities.Designer.cs
:
public partial class Product : EntityObject
{
// ...
public int? SupplierID { get; set; }
public Supplier Supplier { get; set; }
// ...
}
public partial class Supplier : EntityObject
{
public int SupplierID { get; set; }
public EntityCollection<Product> Products { get; set; }
// ...
}