0

我有一个字符串列表,我需要将其保存到关系实体中。

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

我收到以下错误:

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.
4

1 回答 1

1

它告诉您它无法将数据保存到,TrustSettingEmailAddress因为它很可能没有在您的模型中定义主键。DefiningQuery如果您尝试将没有主键的数据库视图或表添加到 EDMX,则会自动使用。这也发生在多对多关系中的联结表上。

于 2012-08-07T15:43:57.250 回答