【发布时间】:2016-09-28 23:35:19
【问题描述】:
我正在尝试将数据保存在数据库中。表名是product_color。
public void PostAddColour1()
{
product_color pc = new product_color();
pc.id = 999;
pc.product_id=2;
pc.color_id=1;
pc.display_order=3;
db.product_color.Add(pc);
db.SaveChanges();
}
这是向表中插入数据的函数代码。
当db.SaveChanges(); 被调用时,会出现以下错误:
Unable to update the EntitySet 'product_color' because it has a
DefiningQuery and no <InsertFunction> element exists in the
ModificationFunctionMapping> element to support the current operation.
【问题讨论】:
-
你的表'product_color'有主键吗?
标签: c# entity-framework