Building Entities with the LINQ to SQL Designer

As an alternative to building entities by hand, you can use the LINQ to SQL Designer. You can simply drag database tables from the Database Explorer (Server Explorer) onto the Designer. The Designer generates the entity classes with the correct attributes automatically.

Follow these steps to use the LINQ to SQL Designer:

  1. Select Website, Add New Item to open the Add New Item dialog box.
  2. Select the LINQ to SQL Classes template, give it the name MyDatabase, and click the Add button.
  3. When prompted to create the LINQ to SQL classes in the App_Code folder, click the Yes button.
  4. After the LINQ to SQL Designer opens, drag one or more database tables from the Database Explorer/Server Explorer window onto ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.