我编写了以下 C# 代码:
abcEntities entities = new abcEntities();
abc_Lids_New newUserEntry = new abc_Lids_New()
{
Lid = lid,
FName = fname,
LName = lname,
Phone = phone,
};
newUserEntry.abc_class_Assignments_New = new System.Data.Objects.DataClasses.EntityCollection<abc_class_Assignments_New>();
foreach (string classId in classIds)
{
newUserEntry.abc_class_Assignments_New.Add(new abc_class_Assignments_New()
{
Lid = lid,
classID = classId
});
}
entities.abc_Lids_New.AddObject(newUserEntry);
entities.SaveChanges();
该代码应该在 abc_Lids_New 中添加代表新用户的新行。该代码还应该在 abc_class_assignments_new 中添加与用户的盖子和一些类 ID 相对应的行。
但是,我收到一个错误:Unable to update the EntitySet 'UCV_TF_Assignments_New' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
直到最近,我只使用实体框架和存储过程,所以这对我来说是新事物。