Share via


Mex.exe Command Line Reference

[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]

Mex.exe takes one or more Microsoft code name “M” images and outputs Entity Framework files. The valid output types include .edmx files, which describe the conceptual model, the storage model, and the mapping between the two, or C# source files that contain the generated entity definitions. You can also provide a custom T4 template to generate custom output files.

Mex.exe Usage

To use Mex.exe, you must first compile the target image files to include EDM information. This is done by using both the TSql10 and Edm target types during compilation. The following command line creates a Models.mx image from a Models.m source file by using this technique.

m.exe model.m /target:TSql10 /target:Edm /package:Image /out:Model.mx

Mex.exe will use the EDM information in the target image to generate the type of output that you specify. The following command uses Mex.exe to generate an .edmx file.

mex.exe model.mx /target:Edmx

“M” images are typically installed to a target SQL Server 2008 database by using Mx.exe. In Visual Studio 2010, you can use the .edmx file or C# source file to generate an object-layer for accessing the model in the database.

Command-Line Parameter Reference

The following table lists the command-line parameter options for the Mex.exe tool.

Option Alias Description

target:

t

Target output type. Values include None, Edmx, CS, VB, and Custom. (Default = Edmx)

reference:

r

Specifies a comma-separated list of “M” image files that are used to resolve imported references in the target “M” images.

output:

o

Sets the name of the output file. The default name is the name of the input image with an extension that is determined by the target type.

templateAssemblyPath:

tp

Specifies the path to an assembly that contains a custom text template (T4 template). The templateClass option must also be specified.

templateClass:

tc

Specifies the fully-qualified class name of the custom text template. The templateAssemblyPath option must also be specified.

nologo

nologo

Suppresses the display of the tool information header.

?

help, h

Displays command-line help information.

@<file>

@<file>

Read <file> for more parameters.

Remarks

The target option controls the type of output file that is generated. Note that if you specify Custom for the target, then you must also provide a custom text template (also called a T4 template) by using the templateAssemblyPath and templateClass options. For more information about the general design and use of custom text templates, see Generating Artifacts By Using Text Templates.

There are some known issues and limitations of the Mex.exe tool.

  1. The target option does not yet support the use of the VB target type.

  2. The “M” compiler is unable to generate EDM information for an image when that image references external images. This prevents the Mex.exe tool from being used on images that reference external images.

  3. The “M” compiler is unable to generate EDM information for an image that includes more than one module. This prevents the Mex.exe tool from being used on images that include more than one module.

  4. When the target option specifies Edmx, the output file is an ANSI text file. This may cause an issue with tools like Visual Studio that expect the .edmx files to be Unicode.

See Also

Other Resources

"M" Tools