Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
 EDM Generator (EdmGen.exe)
EDM Generator (EdmGen.exe)
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

EdmGen.exe is a command-line used for working with the Entity Data Model (EDM). The EdmGen.exe tool can be used to do the following:

  • Generate the .csdl, .ssdl, and .msl model files that are used by the EDM.
  • Validate an existing model.
  • Produce a source code file that contains the object classes generated from a .csdl file.
  • Create a source code file that contains the view generated from the .ssdl, .csdl, and .msl files.

The EdmGen.exe tool is installed in the .NET Framework directory. In many cases, this is located in c:\windows\Microsoft.NET\Framework\v3.5. You can also access the EdmGen.exe tool from the Visual Studio command prompt (Click Start, point to Programs, point to Microsoft Visual Studio 9.0, point to Visual Studio Tools, and then click Visual Studio Code Name Orcas Command Prompt).

EdmGen /mode:choice [options]

You must specify one of the following modes.

Mode Description

/mode:ValidateArtifacts

Validates the .csdl, .ssdl, and .msl files and displays any errors or warnings.

This option requires at least one /inssdl or /incsdl argument. If /inmsl is specified, the /inssdl and /incsdl arguments are also required.

/mode:FullGeneration

Uses the database connection information specified in the /connectionstring option and generates .ssdl, .csdl, .msl, object layer, and view files.

This option requires a /connectionstring argument and either a /project argument or /outssdl, /outcsdl, /outmsdl, /outobjectlayer, /outviews, /namespace, and /entitycontainer arguments.

/mode:FromSSDLGeneration

Generates .csdl and .msl files, source code, and views from the specified .ssdl file.

This option requires the /inssdl argument and either a /project argument or the /outcsdl, /outmsl, /outobjectlayer, /outviews, /namespace, and /entitycontainer arguments.

/mode:EntityClassGeneration

Creates a source code file that contains the classes generated from the .csdl file.

This option requires the /incsdl argument and either a /project argument or the /outobjectlayer argument. The /language argument is optional.

/mode:ViewGeneration

Creates a source code file that contains the view generated from the .ssdl, .csdl, and .msl files.

This option requires the /inssdl, /incsdl, /inmsl, and either the /project or /outviews arguments. The /language argument is optional.

Option Description

/p[roject]:<string>

Specifies the project name to use. The project name is used as a default for the namespace setting, the name of the EDM files, the name of object source file, and the name of view generation source file. The entity container name is set to <project>Context.

/prov[ider]:<string>

The name of the ADO.NET data provider to be used for SSDL generation. The default provider is the .NET Framework Data Provider for SQL Server (System.Data.SqlClient).

/c[onnectionstring]:<connection string>

Specifies the string that is used to connect to the data source.

/incsdl:<file>

Specifies the .csdl file or a directory where the .csdl file(s) are located. This argument can be specified multiple times so that you can specify several directories or .csdl files. This is useful in cases during entity class or view generation (/mode:EntityClassGeneration or /mode:ViewGeneration) when the conceptual model is split across several files, or when you want to validate multiple models (/mode:ValidateArtifacts).

/refcsdl:<file>

Specifies the additional .csdl file(s) used to resolve any references in the source .csdl file (the file specified by the /incsdl option). The /refcsdl file contains types that the source .csdl file is dependent upon. This argument can be specified multiple times.

/inmsl:<file>

Specifies the .msl file or a directory where the .msl file(s) are located. This argument can be specified multiple times so that you can specify several directories or .msl files. This is useful in cases during view generation (/mode:ViewGeneration) when the conceptual model is split across several files, or when you want to validate multiple models (/mode:ValidateArtifacts)

/inssdl:<file>

Specifies the .ssdl file or a directory where the .ssdl file is located.

/outcsdl:<file>

Specifies the name of the .csdl file that will be created.

/outmsl:<file>

Specifies the name of the .msl file that will be created.

/outssdl:<file>

Specifies the name of the .ssdl file that will be created.

/outobjectlayer:<file>

Specifies the name of the source code file that contains the objects generated from the .csdl file.

/outviews:<file>

Specifies the name of the source code file that contains the views that were generated.

/language:[VB|CSharp]

Specifies the language for the generated source code files. The language defaults to C#.

/namespace:<string>

Specifies the namespace to use. The namespace is set in the .csdl file when running /mode:FullGeneration or /mode:FromSSDLGeneration. The namespace is not used when running /mode:EntityClassGeneration.

/entitycontainer:<string>

Specifies the name to apply to the <EntityContainer> element in the generated EDM files.

/help or ?

Displays command syntax and options for the tool.

/nologo

Suppresses the copyright message from displaying.

The following command generates conceptual schema definition language (CSDL), store schema definition language (SSDL), and mapping specification language (MSL) files, and object and view source code files. The EDM files are generated by using all the tables in the Northwind database. The project name is used for the namespace name, the basis for the entity container name (NWModelContext), and to generate the file names (NWModel.csdl, NWModel.ObjectLayer.cs, NWModel.Views.cs, and so on). The files are created in the current directory.

edmgen /mode:fullgeneration /c:"Data Source=yourServer;
Initial Catalog=Northwind; Integrated Security=SSPI" /p:NWModel

The following command uses the SSDL file to generate CSDL and MSL files and the object and view source code files.

edmgen /mode:fromssdlgeneration /inssdl:c:\data\EmpSkillsModel.ssdl
/outcsdl:c:\data\EmpSkillsModel.csdl /outmsl:c:\data\EmpSkillsModel.msl
/outobjectlayer:c:\data\EmpSkillsModel.cs /namespace:EmployeeSkillsModel
/entitycontainer:EmployeeSkills /outviews:EmpSkillsModel.View.cs

The following command creates a Visual Basic object source code file that contains the classes generated from the .csdl file.

edmgen /mode:entityclassgeneration /incsdl:c:\data\EmpSkillsModel.csdl /outobjectlayer:c:\data\EmpSkillsModel.vb /language:vb
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker