One to One Property

View Entity Dependant Entity Property Configuration Options

One To One Relation

When you want to attach a single, optional related entity to your main entity — such as extra profile details or settings — you can use the AddDependantEntity<T> method. This defines a one-to-one relationship where the current entity (e.g., Employee) may optionally be linked to one record of type T (e.g., EmployeeInfo). Because the related data is not always required, the property is always considered nullable in the parent entity. This setup is useful for separating less commonly used or extended data into its own table.

BlazorForKids does not automatically generate a nested editor for the dependent entity inside the main form. Instead, it provides the structure for this relationship, and it's up to the developer to define how the related entity will be edited. You can create a dedicated EditForm for the dependent entity and decide when and how to show it — for example, as a separate form section, a dialog, or even a full page. This gives you full control over the editing experience while keeping your data model clean and modular.

publicpartialclassEmployee:IBkEntity<Employee,ApplicationDbContext>

{

    publicvoidBkConfiguration(IBkEntityDesigner<Employee,ApplicationDbContext>designer)

    {

// Note: The AddDependantEntity method defines a one-to-one optional relationship.// The property (Employee.EmployeeInfo) is always nullable.        designer.Properties.AddDependantEntity<EmployeeInfo>("EmployeeInfo",c=>

        {

// Sets the label displayed above or next to the nested editor.            c.Label("Employee Info");

// Adds a tooltip for the nested entity section.            c.ToolTip("Employee Info");

// Instructs the framework to include the full EmployeeInfo object when querying Employee data.            c.IncludeToDefaultQuery();

// Additional options like TabIndex, CssClass, HideEditor, and validation rules also apply.        });

    }

}

Comparison of Entity Relationship Property Methods

Method Relationship Type Cardinality Editable UI Navigation Direction Supports Reverse Collection Use Case
AddOneEntity<T> One-to-Many Many records belong to one Dropdown (or searchable dropdown) From child to parent (foreign key) ✅ (via NameOfMany) Link an entity to a parent entity, e.g., Employee → Department
AddManyEntities<T> Many-to-Many Each can have many of the other Checkbox list or multi-select Bidirectional ✅ (via NameOfMany) Assign multiple tags, teams, or roles, e.g., Employee ↔ Teams
AddDependantEntity<T> One-to-One One optional dependent per entity Nested editor (inline form) From owner to dependant Edit embedded entity inline, e.g., Employee → EmployeeInfo
An unhandled error has occurred. Reload 🗙