
Adding LINQ to SQL Data Classes to a Project
Create and edit LINQ to SQL classes by using the O/R Designer.
Note: |
|---|
|
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.
|
To add a LINQ to SQL file to a project
From within a Visual Basic or C# application, on the Project menu, click Add New Item.
Click the LINQ to SQL Classes template.
Either provide an alternative name or keep the default name of DataClasses1.dbml.
Note: |
|---|
The name provided will be the name of the generated
DataContext. For example, using the default name will cause the designer to name the DataContext DataClasses1DataContext.
|
Click Add.
The .dbml file is added to the project and the O/R Designer opens.
After you add a LINQ to SQL file to your project, the empty design surface represents a DataContext ready to be configured. Drag database items from Server Explorer/Database Explorer onto the O/R Designer to create data classes and DataContext methods. The data connection of a DataContext is created based on the first item added to the designer form Server Explorer/Database Explorer.
The following topics provide detailed instructions for creating LINQ to SQL classes and DataContext methods by using the O/R Designer.