SPMetal Tool in SharePoint

SPMetal is a command-line tool that generates entity classes. These classes are primarily used in LINQ to SharePoint queries.

The classes it generates are partial, so you can add members to them in separate, manually created, code files.

SPMetal comes in SharePoint 2010/2013 and it founds in (14 hive for SP2010 and 15 hive for SP2015)


To use SPMETAL tool 

  • Open SharePoint Management Shell as Administrator.
  • Type the following command
SpMetal /web:http://epm /user:domain\spfarm /password:**** 
/namespace:nwind /code:\linqcode\nwind.cs

SPmetal Command

  • The output is C# code file that should be in this location or any desired location that you set.(Default path is C:\Users\current user)SPMETAL output Path(Note: if you need to generate a file code for Visual Basic use vb extension)
  • The  generated a file code should contains classes for your objects in a specific site.this will include a data context object, along with objects for all of your list level content types.

Output code

Enjoy 🙂

See also How to Query using LINQ in SharePoint.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s