This section explains how to set up context and code generation in LinqConnect models.
For the purpose of context and code generation, you may need to create and define folders, into which context and generated code will be saved, as well as other parameters available in the Properties window of the selected template.
The definition of output folders for context and code generation is optional, if such folders are of no importance for you, go directly to Step 9 of the procedure.
To define folders for context and code generation, perform the following sequence of actions:
1. | In your project in the Solution Explorer window, create a folder for context (for example, Context) and a folder for generated code (for example, Entities). |
2. | Navigate to the Model Explorer window, select the template and click to display the Properties window for the selected template. |
![Images_TemplatePropertiesLC](images_templatepropertieslc.png)
3. | In the Output section of the model properties, click the Context Output line and then click the displayed three-dotted button. |
4. | In the Select Project Folder dialog box, select the appropriate folder for the context (for example, the Context folder that was created in Step 1 of this procedure) and click OK. |
5. | In the Output section of the model properties, click the Entities Output line and then click the displayed three-dotted button. |
6. | In the Select Project Folder dialog box, select the appropriate folder for entities (for example, the Entities folder that was created in Step 1 of this procedure) and click OK. |
7. | Select an appropriate value for the File Per Class property: if different folders are specified for the context and entities, the File Per Class parameter must be set to True. |
8. | Set the Generate Partial Class property to True define that for each class of the model a partial class should be generated, in which it will be possible to add code that won't be overwritten by the designer. The property can be used, if File Per Class is set to True. |
9. | To enable the entity property validation mechanism in the Validation section locate the Validation Framework row and select the appropriate framework; use the Validation Error Messages row to apply error messages stored in the application resources. For details on validation refer to Entity Property Validation. |
10. | To generate code, save the model, or in the Solution Explorer docking window right-click the model and in its context menu select Run Custom Tool. |
|
To generate code in the standalone application, click the Generate Code button on the application toolbar.
|
Entities and context files are successfully generated and stored in the specified folders:
![Images_File_GenLC](images_file_genlc.png)
|
In case during validation some errors are found, they are displayed in the Error List docking window and code is not generated.
|
This completes the procedure for creating a model from the existing database.
|