Reputation: 588
I work in EF.Xml definition table is ...
<EntityType Name="ShippingCards">
<Key>
<PropertyRef Name="ShippingCardID" />
</Key>
<Property Name="ShippingCardID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="ProducedID" Type="int" />
<Property Name="User" Type="int" />
<Property Name="Count" Type="int" />
</EntityType>
methode is definition
public void addProduct(Product product)
{
ShippingCard sc = new ShippingCard();
sc.ProducedID = product.ProductID;
Add(sc);
context.SaveChanges();
}
When you try to put in the product in the cart breaks my mistake
{"A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'ShippingCardID'."}
InnerError: {"A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'ShippingCardID'."}
Upvotes: 0
Views: 3254
Reputation: 364269
You have incorrectly defined relations between entities. This error says that ShippingCardID
is used as foreign key (= dependent property) in some relation which is not allowed because only properties with StoreGeneratedPattern.None
can be used as foreign keys.
Upvotes: 4