Error Enforcing Referential Integrity Because Relationship: “Contains values that reference one or more non-existent items in the target list”

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/4691

  •  16-10-2019
  •  | 
  •  

문제

When I try to enforce referential integrity like this:

fieldLookup.Indexed = true;
fieldLookup.RelationshipDeleteBehavior = SPRelationshipDeleteBehavior.Restrict
fieldLookup.Update()

It works for most, but not all of the fields in my app. When it fails it looks like this:

Microsoft.SharePoint.SPException: This lookup column cannot enforce a relationship behavior because it contains values that reference one ore more non-existent items in the target list. 
---> System.Runtime.InteropServices.COMException (0x810705B0): 
<nativehr>0x810705b0</nativehr><nativestack></nativestack>This lookup column cannot enforce a relationship behavior because it contains values that reference one ore more non-existent items in the target list.
  at Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateField(String bstrUrl, String bstrListName, String bstrXML)
  at Microsoft.SharePoint.Library.SPRequest.UpdateField(String bstrUrl, String bstrListName, String bstrXML)
  --- End of inner exception stack trace ---
  at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
  at Microsoft.SharePoint.Library.SPRequest.UpdateField(String bstrUrl, String bstrListName, String bstrXML)
  at Microsoft.SharePoint.SPField.UpdateCore(Boolean bToggleSealed)
  at Microsoft.SharePoint.SPField.Update()
  at MyApp.Features.Service.EntityBuilder.EntityBuilderBase.EnforceReferentialIntegrity()

Incidentally, I get this exact same error when click "Enforce relationship behavior" in the properties of the field in the browser.

I've looked in Reflector, but this error is happening in unmanaged code, so I'd be just as happy if anyone could provide any additional debugging techniques.

Thanks, - Lee

도움이 되었습니까?

해결책

Do the lists have items in them already? This works best when setting up up two empty lists.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top