Friday, September 9, 2011

Enable Visual Studio IntelliSense for your SPMetal parameters XML file

We’re big fans of the CKSDev extensions for SharePoint 2010 development here at Rightpoint, especially the integrated SPMetal generation. After you add an initial model block to a Visual Studio SP2010 project, you’ll typically want to tweak and massage your model output to fit your development needs via the XML configuration file. The syntax, however, is very specific and easy to mess up. You could edit it blind and reference the MSDN schema documentation but that’s lame when you have a powerful IDE. Where’s the dang IntelliSense, Visual Studio?!!

Add a reference to SPMetal’s XSD

Luckily, the SharePoint team did include an XSD file but you have to manually tell Visual Studio where to look.

  1. Open the XML file and choose XML > Schemas from the toolbar
  2. Click Add & browse to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML (aka your SharePoint 14 root + “\TEMPLATE\XML”. YMMV)
  3. Select SPMetalParameters.xsd
  4. Click Open and then OK until you’re back to the editor

Bam! IntelliSense.

spmetal_intellisense