Introduction

In parts one, two and three of this four-part series, we discussed the file differences between EDMX & csdl, ssdl & msl files, we looked at the model & code generation APIs available in the .Net Runtime, and we looked at the validation and view-generation APIs. In this final installment of the series, we tie everything together into a command-line tool we call EdmGen2.exe .

EdmGen2.exe

In the previous installments of this series, we illustrated EDM tooling functions from the command line using EdmGen.exe & c/m/s files, and we looked at using the Entity Framework APIs with an EDMX file. Now, we combine the code examples in the preceding parts, along with a few extra functions, to make a command-line tool we’ll call EdmGen2.exe.

EdmGen2.exe is similar in functionality to EdmGen.exe, but understands how to read & write the EDMX file format. Below is the usage statement for EdmGen2.exe. As you can see, in addition to performing the functions discussed in previous parts of this series, it will also combine c/m/s files into an EDMX, as well as extract c/m/s files from an EDMX.

Usage: EdmGen2 [arguments]
          /FromEdmx <edmx file>
          /ToEdmx <csdl file> <msl file> <ssdl file>
          /ModelGen <connection string> <provider name> <model name>
          /ViewGen cs|vb <edmx file>
          /CodeGen cs|vb <edmx file>
          /Validate <edmx file>

The code for all of EdmGen2.exe is available for download at http://code.msdn.microsoft.com/EdmGen2. Examples of usage are shown in Table 1 below.

Function Example
Model generation EdmGen2 /ModelGen "Data Source=C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Samples\Northwind.sdf" System.Data.SqlServerCe.3.5 SqlCENorthwind
Breaking an EDMX into c/m/s files EdmGen2 /FromEdmx SqlCENorthwind.edmx
Building an EDMX from c/m/s files EdmGen2 /ToEdmx SqlCENorthwind.csdl SqlCENorthwind.msl SqlCENorthwind.ssdl
Validating an EDMX EdmGen2 /Validate SqlCENorthwind.edmx
Compiling mappings EdmGen2 /ViewGen cs SqlCENorthwind.edmx
Performing CodeGen EdmGen2 /CodeGen cs SqlCENorthwind.edmx

Table 1. Example commands for EdmGen2.exe

Conclusion

This concludes our four-part series looking at the different ways to access EDM tooling functionality. We hope that this series gave you some insight into the available options for the EDM tooling functionality, and we hope that the sample code and EdmGen2.exe utility are useful. We look forward to your feedback, and thanks for reading!