Classes are basic elements designed for describing the data structure within a model. Classes are composed of properties and describe presentation of high level architecture such as fields and tables of a database. On the diagram, classes are represented as light-blue (by default) shapes, that can be moved, resized, collapsed, etc. Visual presentation of classes on the diagram can be customized, for details refer to Diagram Skins and Shape Colors section.
Classes can be added to the model either by dragging existing tables from the Database Explorer, or by creating a new class manually.
To create a new class manually, use one of the following ways:
• | Click the New Class button on the Model toolbar. |
• | Click the New Class button on the Model Explorer toolbar, this will add a new class to the model only. |
• | Press ALT+C shortcut keys. |
• | Right-click the diagram and select New Class from the Add submenu of the shortcut menu. |
• | Right-click the Classes node in the Model Explorer window and select the New Class menu command, this will add a new class to the model only. |
• | Select New Class from the Model menu (available in the standalone application only). |
Any of these actions calls the Class Editor dialog where you can set parameters for the class and create class properties.
To create an empty class with the default name:
• | Press the INSERT key in the Classes node of the Model Explorer window, in this case the class will not be displayed in the diagram area; |
• | Press the INSERT key in the active digram area, this will add an empty class both in the diagram and in the model. |
To add an existing class from the Model Explorer window to the diagram area together with the objects related to it, right-click the required class in the Model Explorer window and then select the Add On Diagram With Related context menu option.
Apart from dragging objects from Database Explorer to the model, the Database Explorer window has a set of means designed for adding new classes to a model. These means are implemented as context menu options of a table in Database Explorer:
• | Add To Model - this option adds a table selected in the Database Explorer window to the model, in this case the class will not be displayed in the diagram area; |
• | Add To Model With Related - this option adds a table selected in the Database Explorer window to the model together with objects related to it; in this case the class and the related objects will not be displayed in the diagram area. |
You can generate record types instead of classes with the C# EF Core template if model Target Framework is .NET 5 or higher. For this, select a class on the diagram and set its Record Type property to True in the Properties window.
|
To edit a class, do the following:
1. | Double-click the class on the diagram or in the Model Explorer. The Class Editor dialog box will be displayed. |
2. | In the Class Editor dialog box, set class parameters and edit class properties as required. |
3. | To input summary information about the class, go to the Documentation Editor by clicking the Documentation... button. |
4. | To add a property, use either the shortcut menu of the Class Properties grid, or the INSERT key. The Property Editor dialog will be displayed where you can set the property parameters. This dialog can also be called by selecting the required class and pressing ALT+P. For more information on properties, see the Working with Properties section. |
5. | To change the order of properties within a class, drag the properties to their right places in the class on the diagram or in the Model Explorer window. |
|
Renaming a class or property (as well as some other model objects) will be taken into account during the process of code refactoring that is run after the model is saved. Note that the refactoring feature is available only in Entity Developer installed as a Visual Studio add-in.
|
|
To delete a class use one of the following options:
• | in case you want to delete the class from the diagram area only, select it in the diagram area and press SHIFT+DELETE; |
• | right-click the required class on the diagram area or in the Model Explorer, and select Delete in the context menu or select the required class and press the DELETE key. |
Entity Developer will then ask you whether you want to delete the object from the model too.
|
Send feedback on this topic
© 2008 - 2024 Devart. All rights reserved.