I encountered compile-time errors in both the test project and Razor pages due to generated code referencing properties:
- A multilingual property (and thus not present in the DTO), or
- Has Create/Update unchecked in the code generator UI.
Reproduction Steps: In the entity property configuration window, uncheck the "Create and Update" option for a property (e.g., Name).
Leave other options like "List in UI" and "List in Maui" enabled.
Complete code generation.
Observe that the generated test and Razor page still reference the excluded property.
The "Create and Update" checkbox was left unchecked
Error 1 — Test Project
'CreateOrEditContinentDto' does not contain a definition for 'Name' In the generated unit test:
var continent = new CreateOrEditContinentDto { Name = "Updated test value", // Not in DTO due to unchecked Create/Update or Multilingual Property ... }; Error 2 — Razor Page
CS1061: 'CreateOrEditContinentModel' does not contain a definition for 'Name' File: CreateOrEditContinent.razor, Line: 19 This happens because the Razor view is binding to a property that doesn't exist in the generated view model.
Notes: This is not a critical issue — manual removal of lines fixes it.
But if multiple properties are excluded and referenced inconsistently, manual cleanup becomes error-prone and time-consuming.
Suggested Fix: During code generation:
- Exclude properties from test initialization and assertions if "Create and Update" is unchecked.
- Similarly, skip rendering or binding in Razor pages and view models for such properties.
- Multilingual Entity Create page may require more than this , i have not test it
5 Answer(s)
-
0
Hi @sailoper
Can you share the entity json files where you experience this situation with us after hiding the secret information? I will test this issue in the Power Tools development environment. I think we have fixed this. Thanks for your help.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
I've checked my powertools version, it was 4.6.2 may be it is outdated. Here is the Json file
``{ "IsRegenerate": false, "MenuPosition": "Definitions>Geography", "RelativeNamespace": "Geography", "EntityName": "Continent", "EntityNamePlural": "Continents", "TableName": "Continents", "PrimaryKeyType": "int", "BaseClass": "FullAuditedEntity", "EntityHistory": true, "AutoMigration": true, "UpdateDatabase": true, "CreateUserInterface": true, "CreateViewOnly": true, "CreateExcelExport": true, "CreateExcelImport": true, "IsNonModalCRUDPage": false, "IsMasterDetailPage": false, "GenerateOverridableEntity": false, "GenerateUnitTest": true, "GenerateUiTest": true, "GenerateMobile": true, "PagePermission": { "Host": true, "Tenant": false }, "Properties": [ { "Name": "Name", "Type": "string", "MaxLength": 32, "MinLength": 1, "Range": { "IsRangeSet": false, "MinimumValue": 0.0, "MaximumValue": 0.0 }, "Required": true, "Nullable": false, "Regex": "", "IsMultiLingual": true, "UserInterface": { "AdvancedFilter": true, "List": true, "ListMaui": true, "CreateOrUpdate": true }, "ViewType": null, "AdditionalData": {} }, { "Name": "IsoCode2", "Type": "string", "MaxLength": 2, "MinLength": 2, "Range": { "IsRangeSet": false, "MinimumValue": 0.0, "MaximumValue": 0.0 }, "Required": true, "Nullable": false, "Regex": "", "IsMultiLingual": false, "UserInterface": { "AdvancedFilter": true, "List": true, "ListMaui": true, "CreateOrUpdate": true }, "ViewType": null, "AdditionalData": {} }, { "Name": "IsoCode3", "Type": "string", "MaxLength": 3, "MinLength": 3, "Range": { "IsRangeSet": false, "MinimumValue": 0.0, "MaximumValue": 0.0 }, "Required": true, "Nullable": false, "Regex": "", "IsMultiLingual": false, "UserInterface": { "AdvancedFilter": true, "List": true, "ListMaui": true, "CreateOrUpdate": true }, "ViewType": null, "AdditionalData": {} }, { "Name": "NumericCode", "Type": "int", "MaxLength": 0, "MinLength": 0, "Range": { "IsRangeSet": true, "MinimumValue": 1.0, "MaximumValue": 150.0 }, "Required": false, "Nullable": false, "Regex": "", "IsMultiLingual": false, "UserInterface": { "AdvancedFilter": true, "List": true, "ListMaui": true, "CreateOrUpdate": true }, "ViewType": null, "AdditionalData": {} } ], "NavigationProperties": [], "NavigationPropertyOneToManyTables": [], "EnumDefinitions": [], "DbContext": null }
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @sailoper
Thank you for your feedback. I have created an issue for the first error and you can track the progress from there. The second error has been resolved in the development version. These issues are planned to be fixed with version 14.2. Thank you.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
I tried to add my git account but i did not get any invitation, i can not follow up the issues .
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @sailoper
After accepting the GitHub invitation, an "Accept" button should appear on the following page: https://github.com/aspnetzero. If you don’t see the button there, try removing and re-adding your GitHub username from the GitHub Members page on aspnetzero.com. This may resolve the issue.
If that still doesn’t work, please contact [email protected] via email.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)