Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

column names including ID are skipped by generator #5283


User avatar
0
kpmg created

When extending tables in the database and trying to regenerate or update existing entities, columns with phrase ID and any type except numeric are skipped by the generator.

Example of table with GUID columns:

[Table(nameof(Company))]
    public partial class Company : AuditedEntity, IMayHaveTenant, ISoftDelete
    {
        public int? TenantId { get; set; }

        public bool IsDeleted { get; set; }

    }

    public partial class Company
    {
        [Column("companyGUID")]
        public Guid CompanyGuid { get; set; }

        [Column("name")]
        [StringLength(255)]
        public string Name { get; set; }

... other columns

        [Column("hierarchicalFatherGUID")]
        public Guid? HierarchicalFatherGuid { get; set; }

        [Column("taxGroupFatherGUID")]
        public Guid? TaxGroupFatherGuid { get; set; }

        [Column("isTaxGroupHead")]
        public bool? IsTaxGroupHead { get; set; }

    }

When opening 'Load Entity From Database' GUID columns are not detected. Hence created entities and services do not inlcude GUID columns and would overwrite valid entities. To avoid this we manually update entities with dotnet ef tool. We work around this by manually editing Company.json in directory \aspnet-core\AspNetZeroRadTool and then regenerate services and views.

Can you fix this soon?

Thanks a lot!


2 Answer(s)
  • User Avatar
    0
    yekalkan created

    Column names that ends with "Id" are skipped intentionally, because they are most likely primary or foreign keys. It skips the primary keys since every entity should inherit from Entity<T> base class. Also, it skips the foreign keys because they are most likely going to be a navigation property and it may lead to a mismatch in generated code. There may be some situations that column name ends with "Id" when it's a primitive column, we will make it better in next release.

    Main aim of the 'Load Entity From Database' feature is to decrease the time wasted on creating tables with many primitive types. Then you can set primary key and navigation properties. I think you should be able to generate what you want without editing the json file. If not, please inform us why.

    When opening 'Load Entity From Database' GUID columns are not detected.

    We'll fix this in next release.

  • User Avatar
    0
    kpmg created

    hello @yelkalkan, thanks for this hint.

    We also discovered that GUID columns must be omitted for filtering because they are always read in the GetAll call by input.guidName.ToString(). It would be nice if the generator UI would provide more documentation about that. Of course we will exclude the GUID / uniqueidentifier columns from filtering DTOs.