Imtech Get SPMetal Definition Extension

, , , ,

SPMetal is a part of the new SharePoint development toolset that allows you to generate the definitions for use with Linq to SharePoint. In the current release SPMetal is a command-line tool. At least it was, because using Imtech Get SPMetal Definition Extension you can use it from your SharePoint Server Explorer in Visual Studio!

Imtech Get SPMetal Definition Extension is an extension for the new Visual Studio SharePoint development tools. Upon installation it adds an extra menu item called Get SPMetal definition to every site node in the SharePoint Server Explorer.

New ‘Get SPMetal definition’ menu option added to every Site Node in the SharePoint Server Explorer

This menu option executes the SPMetal tool with the URL of the Site currently selected in the SharePoint Server Explorer. The generated definition is being displayed in Visual Studio so that you can easily add it to your project.

SPMetal definition generated using the Imtech Get SPMetal Definition Extension is displayed as a new file in Visual Studio

At this moment the Imtech Get SPMetal Definition Extension supports only C#. If you are a VB developer and you like this extension, just let me know and I will add the option to generate VB code as well.

Download: Imtech Get SPMetal Definition Extension from Visual Studio Gallery or search for Imtech Get SPMetal Definition Extension from the Visual Studio Extension Manager.

Possibly related posts

12 Responses to “Imtech Get SPMetal Definition Extension”

  1. Jeremy Thake Says:

    you beat me to it! but good work mate, downloading it now!

  2. Jeremy Thake Says:

    Just tested it…
    at bottom of code file it outputs:
    "Warning: All content types for list Form Templates were excluded." So the code doesn't compile.

    Also, it doesn't automatically add to project, just simply opens a new unsaved file. If I click save and select a location it doesn't actually add it to project. Be nice if it did this ;-)
    Be cool if it added the references to dlls required too like Microsoft.SharePoint.Linq.

    Found also that having this switched on made the right click context menu take longer to pop up…are you doing some checking on whether it should show on node or not?

    Great work though mate…I'll be following in your footsteps with SPSource integration too.

  3. Waldek Mastykarz Says:

    @Jeremy: Thanks for the feedback: great stuff :D

    SPMetal ships with two options: output code to command line and to a code file. Perhaps the code file option doesn't include the comment at the end…

    Adding to the current project is not an issue, but WHERE in the current project would you like to add it? Something like checking for currently selected item, etc.?

    While adding the item to the menu I don't do any checks, but the extension needs to be loaded. Perhaps that's the penalty that you're seeing.

    Thanks again, mate :)

  4. Waldek Mastykarz Says:

    @Jeremy: It turns out that the string at the end is just SPMetal. When writing the output to a file the remark is being displayed on the screen. While printing on the screen it's just there below the generated code. I guess I'll have to solve it using a temp file for the code.

  5. Jeremy Thake Says:

    it'll keep you busy for atleast another 5 mins ;-)

  6. Scot Hillier Says:

    Cool, but what I really want is to do it for a selected list or content type using the parameters.xml. That way, I don't get everything for the site – just the items I want.

    Scot

  7. Waldek Mastykarz Says:

    @Scot: cool idea! What could be done is to extend the List and Content Type nodes and then generate the parameters.xml in the background and use those while running SPMetal.

    Thanks Scot!

  8. Oscar Bautista Says:

    I am trying to use SPMetal. When I enter the command and run it I keep getting Object Reference Not Set to an instance of an Object".

    I do not know how to get past this?

  9. Waldek Mastykarz Says:

    @Oscar: With SPMetal you mean the .exe that ships with SharePoint 2010 or the extension that I made?

  10. Oscar Bautista Says:

    I am trying to use SPMetal that shipped with VS. Below is my command. The strange thing is that it worked once, but not it isnt working.

    SPMETAL /web:http://www.technologyblends.com /namespace:TechnologyBlends /code:TechnologyBlends.cs

    I also tried using your tool and I cannot get that working. I am able to create a SharePoint connection. It sees my site, but when I click to Expand (plus sign) on Sites I get this error:

    Server Explorer Error:
    Unable to retrieve information for this node, possibly because the node has been deleted or its connection disrupted. If the item exists in SharePoint, be sure it is accessible.

  11. Waldek Mastykarz Says:

    @Oscar: perhaps your Site (Collection) is broken? Have you tried creating a new Site (Collection) and trying to use SPMetal/SharePoint Explorer?

  12. Oscar Bautista Says:

    Thanks so much. My site collection was broken like you suggested. I created a new one and ported the data over.

    Thanks -

Leave a Reply

Security Code:

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS
Copyright © 2007 - 2010 Waldek Mastykarz

Creative Commons License