Entities
Entity definitions need to follow certain rules in order to work with Xams.
Entity Rules
- Entities must have a string Name field or a string field with the attribute
UINamefor lookup fields. - Composite Primary Keys are not supported.
- Self-referencing entities must NOT include navigation properties to themselves.
- System entities use base table names:
User,Team,Role,Settingare always the table names—even when extended (e.g.,public class AppUser : User→ table name is"User"for queries and permissions).
Field Types: UIOption vs Enums
Never use C# enums for user-facing choice fields. Always use [UIOption("GroupName")] instead.
Project / Entities / Post.cs
Why UIOption?
- Options are manageable via Admin Dashboard without code changes
- Supports dropdown UI components automatically
- Values can be added/modified at runtime
- See Attributes for UIOption setup details
Self-Referencing Entities
For entities that reference themselves (like nested comments), use only the ID field - do not include the navigation property.
Project / Entities / Comment.cs
Navigation properties on self-referencing entities cause nullable reference errors during queries. Use only the ID field and query parent/child records separately if needed.
Cascade Delete
Configure cascade delete using the nullable operator ? and the CascadeDelete attribute.
Project / Entities / Widget.cs
When a user deletes a record, delete permissions are checked only on the record being deleted—not on any dependent records removed through cascading. This behavior is consistent with how enterprise CRM systems operate.