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
- 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)(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.
See also How to Query using LINQ in SharePoint.