|
| 1 | +# Creating Entity Json File Manually |
| 2 | + |
| 3 | +In this document, we will explain how to use **ASP.NET Zero Power Tools** without the Visual Studio extension. |
| 4 | + |
| 5 | +Purpose of the **ASP.NET Zero Power Tools VS Extension** is to create an input file. So, in order to use it without extension, input file needs to be created manually. |
| 6 | + |
| 7 | +## Creating Input File |
| 8 | + |
| 9 | +For creating JSON file manually, you need to learn fields of the JSON file (configuration for entity). |
| 10 | + |
| 11 | +Properties are written as an array in JSON file. Add an object to that array for every property of your entity. There will be some unnecessary fields depending on property type. For example, you don't have to set regular expression for a numeric property or don't have to set range for a string. |
| 12 | + |
| 13 | +You have to fill the fields of the JSON file for your entity. However, some of the fields must match our constants. |
| 14 | + |
| 15 | +A property should be one of those types: |
| 16 | + |
| 17 | +* bool |
| 18 | +* byte |
| 19 | +* short |
| 20 | +* DateTime |
| 21 | +* decimal |
| 22 | +* double |
| 23 | +* Guid |
| 24 | +* int |
| 25 | +* long |
| 26 | +* string |
| 27 | + |
| 28 | +or one of the ENUMs you declared in **EnumDefinitions**. |
| 29 | + |
| 30 | +You can find specification of the JSON file fields in the table below; |
| 31 | + |
| 32 | +## Fields Table |
| 33 | + |
| 34 | +| Name | Description | |
| 35 | +| --- | --- | |
| 36 | +| IsRegenerate | Set `true` if you have generated this entity before. | |
| 37 | +| MenuPosition | `main` or `admin` | |
| 38 | +| RelativeNamespace | Namespace of your entity (not including project's namespace) | |
| 39 | +| EntityName | Entity Name | |
| 40 | +| EntityNamePlural | Entity Name Plural | |
| 41 | +| TableName | Database Table Name (might be same with plural name) | |
| 42 | +| PrimaryKeyType | Type of primay key. <br />Can be `int`, `long`, `string`, `Guid` | |
| 43 | +| BaseClass | Base class of your entity. <br />Can be `Entity`, `AuditedEntity`, `CreationAuditedEntity`, `FullAuditedEntity` | |
| 44 | +| EntityHistory | Set `true` to track history of this entity. | |
| 45 | +| AutoMigration | `true` add-migration automatically, false do not add migration (you need to add migration manually) | |
| 46 | +| UpdateDatabase | `true` update-database automatically, false do not update-database (you need to update-database manually) | |
| 47 | +| CreateUserInterface | `true` creates/modifies ui layer files | |
| 48 | +| CreateViewOnly | `true` creates a view-only modal in actions button in table of your entity in ui | |
| 49 | +| CreateExcelExport | `true` adds excel report button in ui | |
| 50 | +| IsNonModalCRUDPage | `true` creates non-modal pages. | |
| 51 | +| PagePermission | Multitenancy<br />`"PagePermission":{"Host": [ISHOSTALLOWED],"Tenant":[ISTENANTALLOWED]}` | |
| 52 | +| Properties | Properties of your entity. See **Properties Table** for more. | |
| 53 | +| NavigationProperties | Navigation properties of your entity. See **NavigationProperties Table** for more. | |
| 54 | +| EnumDefinitions | Enum definitions you use on your entity. See **EnumDefinitions Table** for more. | |
| 55 | + |
| 56 | +## Properties Table(Array): |
| 57 | + |
| 58 | +| Name | Description | |
| 59 | +| --- | --- | |
| 60 | +| Name | Property Name | |
| 61 | +| Type | Type of property. <br />Can be string, bool, byte, short, DateTime, decimal, double, Guid, int, long, enum | |
| 62 | +| MaxLength | If type is string max length of string | |
| 63 | +| MinLength | If type is string min length of string | |
| 64 | +| Range | If type can have range value range of property<br />"Range": {"IsRangeSet": [ISRANGESET],"MinimumValue": [MINVAL],"MaximumValue": [MAXVAL]} | |
| 65 | +| Required | Is property required | |
| 66 | +| Nullable | Is property nullable | |
| 67 | +| Regex | specifies the regex that this property should match | |
| 68 | +| UserInterface | Will this property be listed, have a filter and editable in ui?<br />"UserInterface": {"List": true,"AdvancedFilter": true,"CreateOrUpdate": true} | |
| 69 | + |
| 70 | +## NavigationProperties Table(Array): |
| 71 | + |
| 72 | +| Name | Description | |
| 73 | +| --- | --- | |
| 74 | +| Namespace | Namespace of entity | |
| 75 | +| ForeignEntityName | Foreign Entity Name | |
| 76 | +| ForeignEntityNamePlural | Foreign Entity Name Plural | |
| 77 | +| IdType | Type of Foreign Key. See Entity -> PrimaryKeyType | |
| 78 | +| IsNullable | Is nullable | |
| 79 | +| PropertyName | Property name (Property name for that entity which will store Foreign Key) | |
| 80 | +| DisplayPropertyName | Property name of foreign entity. It will be displayed by that property on pages. | |
| 81 | +| DuplicationNumber | If you have two navigation property that navigates to same foreign entity, number them starting from 1. If not, just skip this. | |
| 82 | +| RelationType | single is the only option. | |
| 83 | + |
| 84 | +## EnumDefinitions Table: |
| 85 | + |
| 86 | +| Name | Description | |
| 87 | +| --- | --- | |
| 88 | +| Name | Name | |
| 89 | +| Namespace | Namespace | |
| 90 | +| EnumProperties | Properties <br />"EnumProperties":[{"Name":"[PROPERYNAME]","Value":[PROPERYVALUE]}] | |
| 91 | + |
| 92 | +## Example JSON Input |
| 93 | + |
| 94 | +```json |
| 95 | +{ |
| 96 | + "IsRegenerate": false, |
| 97 | + "MenuPosition": "main", |
| 98 | + "RelativeNamespace": "Products", |
| 99 | + "EntityName": "Product", |
| 100 | + "EntityNamePlural": "Products", |
| 101 | + "TableName": "Products", |
| 102 | + "PrimaryKeyType": "int", |
| 103 | + "BaseClass": "Entity", |
| 104 | + "EntityHistory": false, |
| 105 | + "AutoMigration": true, |
| 106 | + "UpdateDatabase": true, |
| 107 | + "CreateUserInterface": true, |
| 108 | + "CreateViewOnly": true, |
| 109 | + "CreateExcelExport": true, |
| 110 | + "IsNonModalCRUDPage": false, |
| 111 | + "PagePermission": { |
| 112 | + "Host": true, |
| 113 | + "Tenant": true |
| 114 | + }, |
| 115 | + "Properties": [ |
| 116 | + { |
| 117 | + "Name": "Name", |
| 118 | + "Type": "string", |
| 119 | + "MaxLength": 25, |
| 120 | + "MinLength": 2, |
| 121 | + "Range": { |
| 122 | + "IsRangeSet": false, |
| 123 | + "MinimumValue": 0, |
| 124 | + "MaximumValue": 0 |
| 125 | + }, |
| 126 | + "Required": true, |
| 127 | + "Nullable": false, |
| 128 | + "Regex": "", |
| 129 | + "UserInterface": { |
| 130 | + "List": true, |
| 131 | + "AdvancedFilter": true, |
| 132 | + "CreateOrUpdate": true |
| 133 | + } |
| 134 | + }, |
| 135 | + { |
| 136 | + "Name": "Type", |
| 137 | + "Type": "ProductType", |
| 138 | + "MaxLength": 0, |
| 139 | + "MinLength": 0, |
| 140 | + "Range": { |
| 141 | + "IsRangeSet": false, |
| 142 | + "MinimumValue": 0, |
| 143 | + "MaximumValue": 0 |
| 144 | + }, |
| 145 | + "Required": false, |
| 146 | + "Nullable": false, |
| 147 | + "Regex": "", |
| 148 | + "UserInterface": { |
| 149 | + "List": true, |
| 150 | + "AdvancedFilter": true, |
| 151 | + "CreateOrUpdate": true |
| 152 | + } |
| 153 | + } |
| 154 | + ], |
| 155 | + "NavigationProperties": [ |
| 156 | + { |
| 157 | + "Namespace": "Volosoft.RadToolExplainer.Authorization.Users", |
| 158 | + "ForeignEntityName": "User", |
| 159 | + "IdType": "long", |
| 160 | + "IsNullable": true, |
| 161 | + "PropertyName": "UserId", |
| 162 | + "DisplayPropertyName": "Name", |
| 163 | + "DuplicationNumber": 0, |
| 164 | + "RelationType": "single" |
| 165 | + } |
| 166 | + ], |
| 167 | + "EnumDefinitions": [ |
| 168 | + { |
| 169 | + "Name": "ProductType", |
| 170 | + "Namespace": "Volosoft.RadToolExplainer", |
| 171 | + "EnumProperties": [ |
| 172 | + { |
| 173 | + "Name": "Liquid", |
| 174 | + "Value": 1 |
| 175 | + }, |
| 176 | + { |
| 177 | + "Name": "Solid", |
| 178 | + "Value": 2 |
| 179 | + } |
| 180 | + ] |
| 181 | + } |
| 182 | + ] |
| 183 | +} |
| 184 | +``` |
| 185 | + |
| 186 | +> Note: Please Keep in mind that JSON file is completely **case sensitive**. |
0 commit comments