Skip to content

Latest commit

 

History

History
55 lines (46 loc) · 4.26 KB

File metadata and controls

55 lines (46 loc) · 4.26 KB
title How to: Generate the Object Model in Visual Basic or C#
ms.custom
ms.date 03/30/2017
ms.prod .net-framework
ms.reviewer
ms.suite
ms.technology
dotnet-ado
ms.tgt_pltfrm
ms.topic article
ms.assetid a0c73b33-5650-420c-b9dc-f49310c201ee
caps.latest.revision 3
author douglaslMS
ms.author douglasl
manager craigg
ms.workload
dotnet

How to: Generate the Object Model in Visual Basic or C#

In [!INCLUDEvbtecdlinq], an object model in your own programming language is mapped to a relational database. Two tools are available for automatically generating a [!INCLUDEvbprvb] or C# model from the metadata of an existing database.

Documentation for the [!INCLUDEvs_ordesigner_short] provides examples of how to generate a [!INCLUDEvbprvb] or C# object model by using the [!INCLUDEvs_ordesigner_short]. The following information provide examples of how to use the SQLMetal command-line tool. For more information, see SqlMetal.exe (Code Generation Tool).

Example

The SQLMetal command line shown in the following example produces [!INCLUDEvbprvb] code as the attribute-based object model of the Northwind sample database. Stored procedures and functions are also rendered.

sqlmetal /code:northwind.vb /language:vb "c:\northwnd.mdf" /sprocs /functions  

Example

The SQLMetal command line shown in the following example produces C# code as the attribute-based object model of the Northwind sample database. Stored procedures and functions are also rendered, and table names are automatically pluralized.

sqlmetal /code:northwind.cs /language:csharp "c:\northwnd.mdf" /sprocs /functions /pluralize  

See Also

Programming Guide
The LINQ to SQL Object Model
Learning by Walkthroughs
How to: Customize Entity Classes by Using the Code Editor
Attribute-Based Mapping
SqlMetal.exe (Code Generation Tool)
External Mapping
Downloading Sample Databases
Creating the Object Model