EdmGen2 is a command-line tool for the Microsoft ADO.NET Entity Framework. The tool can be used as a replacement for the EdmGen.exe tool that ships with the .Net framework 3.5 SP1. EdmGen.exe can only read and write the CSDL, SSDL & MSL file formats. However, EdmGen2.exe can read and write the EDMX file format used by the Visual Studio design tools. Additionally, EdmGen2.exe can translate between EDMX and CSDL, SSDL & MSL formats, and the source code can act as examples on using the tooling APIs defined in the System.Data.Entity.Design assembly.
Additionaly, EdmGen2.exe contains some experimental functionality not found in EdmGen.exe. Ankit Malpani, an intern with Microsoft Research in summer of 2008, and James Terwilliger, a Post Doc researcher with MSR, updated EdmGen2.exe with the ability to identify inheritance relatationships in relational database schema. You can access this functionality by using the "RetrofitModel" option. The RetrofitModel option connects to a database instance and constructs an EDM model (csdl, msl, ssdl, and edmx files) that includes inheritance. The tool uses data mining techniques to identify TPT and TPH patterns in the database instance, as well as vertical partitioning, and constructs a suitable model and mapping. To use the tool, launch EdmGen2 with the following arguments:
/RetrofitModel "connection string" "provider" "entitiy name"
For instance, the following will connect to a local AdventureWorks database, and create files and an EDM instance named AVWorks:
EdmGen2 /RetrofitModel "Server=(local);Integrated Security=true;Initial Catalog=AdventureWorks;" "System.Data.SqlClient" "AVWorks"
In the previous version (version 1.0.20090401), the RetrofitModel option would bring up a dialog that would allow the user to choose the tables to include in the model. With version 1.0.20091019, the ConceptualEdmGen dll now has two additional public methods that can set the list of tables without bringing up a dialog – one that pulls the list of tables from a file, and one where the list of tables is fed directly to the method as a list of strings.
The EdmGen2 code as it appears in the package uses the “from file” option, where it looks for a file called “Tables.txt” in the current directory, and if found, feeds its contents to the dll to set the list of tables. So for instance, if the following were the contents of the file “Tables.txt”:
HumanResources.Department
HumanResources.Employee
HumanResources.EmployeeAddress
HumanResources.EmployeeDepartmentHistory
HumanResources.JobCandidate
HumanResources.Shift
EdmGen2 would generate (for the RetrofitModel option) a model for all of the tables in the HumanResources schema for AdventureWorks. For both methods, an empty list will result in all tables in the database being added to the model. The table selection UI will still appear if neither table selection method is called.