Rapid Agile Development for Prototyping and Rapid Application Development

Navigation: <Root level>






SQLMetal™ is a Microsoft™ product and is not supplied or supported by Cove Bay Software Limited. The SQLMetal™ Wizard is an intuitive user interface allowing the user to easily create  a relevant parameter list to pass to SQLMetal.exe. SQLMetal.exe must be downloaded and installed prior to using the SQLMetal™ Wizard in kiss!®.


At time of writing, SQLMetal™ does not support all SQL Server Data Types (e.g. HeirarchyID etc). Check https://msdn.microsoft.com/en-us/library/bb386947(v=vs.110).aspx for more details.


More general information about SQLMetal™ can be found here: https://msdn.microsoft.com/en-us/library/bb386987(v=vs.110).aspx


The SQLMetal™ Set Up Wizard is accessed by clicking  on the main toolbar:




SQLMetal.exe generates an Object Model using LINQ to SQL for an entire database in either C# or VB.Net (http://msdn.microsoft.com/en-us/library/bb399337(v=vs.110).aspx).


If the entire database is not required then generating a .map file, editing the xml in the .map file to remove tables and applying the .map file to the generation process will only generate code for the remaining tables in the .map file. At time of writing, SQLMetal.exe did not support all SQL Server 2012 "exotic" Data Types  (e.g. HierarchyID etc) so create a .map file and remove tables with columns using these Data Types.


SQLMetal.exe is a part of the Microsoft™ Windows™ SDK which can be downloaded (if not already installed) from the Microsoft Download Centre (http://www.microsoft.com/en-gb/download/default.aspx)


A typical location for SQLMetal.exe would be (depending on Windows™ and SDK version):


C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\SqlMetal.exe


"The SqlMetal command-line tool generates code and mapping for the LINQ to SQL component of the .NET Framework. By applying options that appear later in this topic, you can instruct SqlMetal to perform several different actions that include the following:

·From a database, generate source code and mapping attributes or a mapping file.

·From a database, generate an intermediate database markup language (.dbml) file for customization.

·From a .dbml file, generate code and mapping attributes or a mapping file.

This tool is automatically installed with Visual Studio. By default, the file is located at drive:\Program Files\Microsoft SDKs\Windows\vn.nn\bin. If you do not install Visual Studio, you can also get the SQLMetal file by downloading the Windows SDK."


Source: http://msdn.microsoft.com/en-us/library/bb386987(v=vs.110).aspx


kiss!® presents a wizard allowing the user to easily and repeatedly generate SQLMetal.exe parameters and execute SQLMetal.exe against the currently loaded Solution's Data Model Database. Selections and entries are saved for the next iteration.


Set the path to SQLMetal.exe in kiss!® Options:




Start the SQLMetal Wizard from the main toolbar:




Either the Data Model or the Test Database can be selected as the target database for SQLMetal:




Select Code Language and other options as required then click "Next >". When generating Code an existing .map file (edited to remove tables) can be used by checking "Use Object Relational Map":




Enter optional Names:




View Command Line Parameters and Generate. Clcik "Generate" to execute SQLMetal.exe with chosen options. If the Parameters are edited here, the edited version will be used by SQLMetal.exe. Click the "Home" icon to go back to Step 1 allowing you to repeat the process with slightly different selections. Once all generation is complete, click "Cancel" then "Refresh" the main form in kiss!®.






The wizard was used (3 times) to generate a .map file, C# file and .dbml file. These became visible in kiss!® after the SQLMetal™ Wizard was closed and "Refresh" was clicked:




If SQLMetal.exe fails to execute correctly against your database then open a command prompt, change to the SQLMetal directory (use Copy SQLMetal Directory to Clipboard) copy the Parameters (use Copy Parameters to Clipboard) and execute SQLMetal.exe using the pasted Parameters. SQLMetal.exe will give error messages at the command prompt once executed.
















www.rapidagiledevelopment.com by Cove Bay Software Limited Copyright © 2015