Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Edited Unassigned: Add foreign key information to the associations in the $metadata document [1094]

$
0
0
When there is an entity in a model that has an entity that explicitly exposes the foreign key of an association to another entity, make that information visible and available in the $metadata document.

For example:

```
<EntityType Name="Customer">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="Name" Type="Edm.String" MaxLength="Max" FixedLength="false" Unicode="true"/>
<NavigationProperty Name="Orders" Relationship="WcfDataServicesForeignKey.Customer_Orders" ToRole="Customer_Orders_Target" FromRole="Customer_Orders_Source"/>
</EntityType>
<EntityType Name="Order">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Name="Id" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity"/>
<Property Name="CustomerId" Type="Edm.Int32" Nullable="false"/>
<Property Name="Purchased" Type="Edm.DateTime" Nullable="false"/>
<Property Name="Total" Type="Edm.Double" Nullable="false"/>
</EntityType>
<Association Name="Customer_Orders">
<End Type="WcfDataServicesForeignKey.Customer" Role="Customer_Orders_Source" Multiplicity="1">
<OnDelete Action="Cascade"/>
</End>
<End Type="WcfDataServicesForeignKey.Order" Role="Customer_Orders_Target" Multiplicity="*"/>
<ReferentialConstraint>
<Principal Role="Customer_Orders_Source">
<PropertyRef Name="Id"/>
</Principal>
<Dependent Role="Customer_Orders_Target">
<PropertyRef Name="CustomerId"/>
</Dependent>
</ReferentialConstraint>
</Association>
```

This is the behavior WCF Data Services implement, and it's required for third party OData client libraries like breeze.js to work against Web API OData properly.


Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>