I'm having this error in this code:
Unable to update the EntitySet 'Ingredient_Quantity' because it has a
DefiningQuery and no <InsertFunction> element exists in the
<ModificationFunctionMapping> element to support the current operation.
The code.
Ingredient ing = new Ingredient();
ing.name = ingredientVM.name;
ing.Ingredient_Type_id = ingredientVM.typeId;
ing.UOM_id = ingredientVM.uomId;
ing.is_deleted = 0;
db.Ingredients.Add(ing);
db.SaveChanges();
int latestIngredientId = ing.id;
Ingredient_Quantity iq = new Ingredient_Quantity
{
Ingredient_id = latestIngredientId,
quantity_as_of = DateTime.Now,
quantity = (double)ingredientVM.quantity
};
db.Ingredient_Quantity.Add(iq);
db.SaveChanges(); // HERE IS WHERE I'M GETTING THE ERROR
From what I am seeing in the internet, it's because that my Ingredient_Quantity
is seeing every column as Entity Key. I don't know if this is right.
How can I change this? Any advice?