SPMetal can generate three types of fields for lookup columns:
- EntityRef: This type of field is generated for lookup columns that accepts single value.
- EntitySet: This type of field is generated for lookup columns that accepts multiple values.
- LookupList: This type of field is generated for lookup columns for lists that are not available to SPMetal in case they are hidden, for example.
In my case, I imported the lists to a standalone “scratch” site with no content by saving list as templates and importing lists to the new site. When I tried to generate the entity class using SPMetal, it created LookupList field for lookup columns instead of generating fields of type EntityRef or EntitySet. When I further looked into this issue, I found that the lookup columns are not being populated from the source lists. One of the drawbacks of saving list as template and importing it to another site is it looses reference to the lookup columns so those fields were being referenced by SPMetal as hidden fields. I then found a tool called “SharePoint Content Deployment Wizard” which allows you to export SharePoint libraries and lists and can also import any dependencies for lookup columns on those lists. You can also import the list to the target site using this tool keeping the object ID and locations so that the relationship is not broken. After doing that, SPMetal generated the fields correctly.
No comments:
Post a Comment