- How to: Use CrmSvcUtil to generate entities using CDS for Code
The CDS for Code extension will call out to the SvcUtil.exe application to generate strongly typed code for your project to use when communicating with CDS. You can read more about creating early bound entity classes here.
To generate entities using the command palette:
- Open the VSCode command palette (Ctrl + Shift + P)
- Search for and select Generate entity code from metadata on a registered CDS environment
- Select the target organization
- Select the target folder
- Type in the desired file name and press enter
- Type in the desired Namespace and press enter
When put into action it will look similar to this:
To generate entites from VSCode File Explorer:
- Right-click on the folder or exact file you want the entites to be generated to
- Select your target organization
- If you selected a folder it will prompt you for a file name
- Type in the desired namespace and press enter
Generating code from File Explorer will look similar to this:
CDS for Code allows for customizing the output of CrmSvcUtil.exe utelizing a CloudSmith utility library. This library allows for configuring the code generation process using a configuration file. CDS for Code will help you generate and customize this file. You can see documentation on configuring this file manually here.
A customizable CrmSvcUtil configuration file can be created by:
- Right-click the directory you want the config file to be generated under
- Click New CrmSvcUtli Configuration
- Enter a file name for the output config file
- Add rules using the Configure entity code generation screen
- Click save
Here's an example of creating one in a templated plugin project:
Right-clicking your config file in VSCode File Explorer will present you the option of editing this configuration using our configuration tool.
In your editor, it will look something like this:
Once you have a customized CrmSvcUtil configuration file, it can be used in place of the default configuration to generate early bound entities.
Inside of VSCode File Explorer:
- Right-click your customized CrmSvcUtil configuration file
- Click Generate CDS entity classes using this configuration
- Select your connection
- Select the location and file name for the generated code
Here's an example of what you will see when right-clicking the file:
This will kick off the code generation process.