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

24 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 -

  13. Tobias Zimmergren Says:

    Awesome work Waldek. I like Scot's suggestion as well, to be able to generate the definitions for selected CT's or lists.

  14. Waldek Mastykarz Says:

    @Tobias: Thanks, man. It's a great suggestion indeed, and the best part is, that it's already there :D

  15. sander Says:

    Hi Waldek,

    awesome extensions! I cannot seem to get the SPMETAL extension working. I just click any site, click on GetSPMETAL Definition and in the output window a line is displayed: Running SPMetal… and that's it. Nothing more, nothing less. I can use SPMETAL as a command line. Any ideas?

  16. Waldek Mastykarz Says:

    @sander: does it work on a site without any customizations whatsoever or doesn't it work at all?

  17. peter zorbas Says:

    Great add-on. I've read a few of your articles and hope to get to more. Do you know why SPMetal does not generated the typical read only columns ie ID, Created By, Modified etc in the class files? I've tried adding include hidden fields flag, but that doesn't seem to work. Any insight?

  18. Waldek Mastykarz Says:

    @peter zorbas: have you tried using the SPMetal command line tool? If so, does it work there or do you see exactly the same behavior as when using the extension?

  19. sander Says:

    Hi,
    It doesn't work at all. Tried on several HYPER-V's. I tried the beta and the final version.

  20. sander Says:

    Hi,
    It doesn\'t work at all. Tried on several HYPER-V\'s. I tried the beta and the final version.

  21. peter zorbas Says:

    Yes, it's just an SPMetal issue I'm finding that it will not generate any of the GUID, Created By, Modified members all SPLists have. Hopefully I'm doing somethign wrong or I'm just missing the point somewhere with the tool because it wouldn't make much sense not to include the default List columns for whatever reason.

    Thanks for you response. I'll post more info if I figure anything out.

  22. peter zorbas Says:

    Yes, it\'s just an SPMetal issue I\'m finding that it will not generate any of the GUID, Created By, Modified members all SPLists have. Hopefully I\'m doing somethign wrong or I\'m just missing the point somewhere with the tool because it wouldn\'t make much sense not to include the default List columns for whatever reason.

    Thanks for you response. I\'ll post more info if I figure anything out.

  23. Waldek Mastykarz Says:

    @peter zorbas: thank you for the additional info, Peter. I will see if I can get any more details about this and will get back to you once I have more information.

  24. Waldek Mastykarz Says:

    @peter: although I don't have a final answer yet, I have a tip for you. Did you know that you can easily extend the generated class with additional columns? You can read more about it @ http://msdn.microsoft.com/en-us/library/ee538669.aspx.

Leave a Reply

Security Code:

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

Creative Commons License