I’ve written the following C# code:
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();
The code is supposed to add a new row in abc_Lids_New representing a new user. The code is also supposed to add rows in abc_class_assignments_new corresponding to the user’s lid and a number of class ids.
However, I am getting an error: 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.
Up until recently, I had only used the Entity Framework with stored procedures, so this is something new to me.
Your
EntitySet“‘UCV_TF_Assignments_New” is either based on aView(in which case, you have to create theInsertFunction(stored procedure)) or it lacks a Primary Key (in which case, add one).