I have a string list which I need to save to a relational entity.
Dim ts = (From t In _repository.GetSettings _
Where t.TrustSettingId = Setting.SettingId).First()
For i As Integer = 0 To emailAddressList.Count()
If(Not emailAddressList(i) = ts.SettingEmailAddresses(i).EmailAddress)
ts.SettingEmailAddresses.Add(New SettingHREmailAddress() With {.EmailAddress = emailAddressList(i)})
End If
Next
I am getting the following error:
Unable to update the EntitySet 'TrustSettingEmailAddress' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
It tells you that it cannot save data to
TrustSettingEmailAddressbecause it most probably doesn’t have primary key defined in your model.DefiningQueryis automatically used if you try to add database view or table without primary key to EDMX. This also happens for junction tables in many-to-many relation.