Imtech Get SPMetal Definition Extension
Development, Productivity, SharePoint 2010, Tools, Visual Studio 2010SPMetal 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.
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.
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.
















November 24th, 2009 at 12:58 pm
you beat me to it! but good work mate, downloading it now!
November 24th, 2009 at 1:07 pm
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.
November 24th, 2009 at 2:17 pm
@Jeremy: Thanks for the feedback: great stuff
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
November 24th, 2009 at 2:40 pm
@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.
November 24th, 2009 at 4:30 pm
it'll keep you busy for atleast another 5 mins
December 5th, 2009 at 10:21 pm
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
December 6th, 2009 at 12:31 pm
@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!
February 9th, 2010 at 11:43 pm
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?
February 10th, 2010 at 8:18 am
@Oscar: With SPMetal you mean the .exe that ships with SharePoint 2010 or the extension that I made?
February 10th, 2010 at 4:10 pm
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.
February 11th, 2010 at 7:41 am
@Oscar: perhaps your Site (Collection) is broken? Have you tried creating a new Site (Collection) and trying to use SPMetal/SharePoint Explorer?
February 12th, 2010 at 8:03 am
Thanks so much. My site collection was broken like you suggested. I created a new one and ported the data over.
Thanks -