This post is a contribution from Aaron Miao, an engineer with the SharePoint Developer Support team.
Create a test site
1. We create a SharePoint site collection named http://intranet.contoso.com/sites/testsite/testexternallist.
**It’s good to use a site which does not have lot of stuffs, best would be to create a new team site or blank site.
2. Activate the following site collection features:
a. SharePoint Server Enterprise Site collection features
b. SharePoint Server Standard Site collection features
Prepare SQL Database table
**You could use Northwind sample database
3. Create a table in SQL database called TestTable.
4. Add some data to it.
Create an external content type and a list instance using SharePoint Designer 2013
5. Open the test site using SPD 2013 and create an external content type ExternalTestCT (reference if you need it).
6. Create external list using SPD 2013 and choose to create InfoPath forms.
The result should look like this.
7. Verify external list works by browsing to it using SharePoint 2013 UI.
8. Make sure the external list displays data successfully in InfoPath forms. “View Item” of the list will display an item in InfoPath form like this:
Prepare Visual Studio SharePoint 2013 project
9. Now save the site as template without content using SPD 2013.
10. This will generate a WSP file in your site collection solution gallery. Download a copy of this WSP and save it to local disk.
Create Visual Studio 2013 project and solution
11. Create a Visual Studio 2013 project of type “SharePoint 2013 – Import Solution Package” and point to the saved WSP. As a reference, this blog walks through the entire process.
**When there’s a warning about dependencies, click “Yes” to have VS 2012 automatically include all dependencies.
12. Once you are done with these steps, you will have the external list instance, with its schema. You will also have Modules with all the InfoPath forms and template.xsn. In addition, you’ll see a PropertyBags module as well. Your project should look like this:
13. Clean up unnecessary files
a. Remove ListsExternalList1_pages item
b. Remove 2 features (3 features are imported. Retain the first feature you see from the top in the list of features and remove the other 2)
c. Make sure the feature includes items: List instances, Modules and PropertyBags.
In the end, your project should look like this:
Details of each file
**Make sure you verify that the external list name is same in the list instance and all the files (schema, module files). There are lots of places the list name and its URL is used.
**<DataSource> provides information of the generated BDC model.
**Type=”600” indicates this is an external list. Fields are defined in the schema.
**There are many properties in the file generated originally. Only the above two are required. Looks like they are related to InfoPath form activation and file persistence.
In the end, you should see the artifacts like in the VS 2012 project attached to this blog post.
Test the solution
18. Deploy the project to another site. You may not see the external list in the quick launch. Navigate to site contents and click the external list. You should see the list and InfoPath item view form.
19. The view form URL should like like what’s shown below. Notice that displayifs.aspx is used and not DispForm.aspx.
Hope this post was helpful!
Sample VS2012 project for download