Auto Incrementing Key Property

View Entity Auto Incrementing Key Property Configuration Options

Auto Incrementing Key Property

The AddAutoIncrementingKey method defines a special backend-only property that stores an auto-incremented value generated by the database. This kind of property is especially useful when you need a sequential counter for records, such as:

  • Invoice Number
  • Contract Number
  • Task ID

Since BlazorForKids uses strongly-typed entity IDs based on Guid, these unique auto-incrementing numbers must be declared separately if you need them. They provide human-friendly identifiers that are easier to read and work with, especially for display, filtering, or sorting.

Once defined, the framework:

  • Marks the property as not editable – users won't be able to change it in forms.
  • Relies on the database to automatically generate its value when a new record is inserted.
  • Lets you use it in the UI wherever you need to show, filter, or sort by the value.

No additional configuration is required. You don’t need to set it manually during insert or update – the value will be available automatically after the record is saved.

publicpartialclassEmployee:IBkEntity<Employee,ApplicationDbContext>

{

    publicvoidBkConfiguration(IBkEntityDesigner<Employee,ApplicationDbContext>designer)

    {

        designer.Properties.AddAutoIncrementingKey("TaskID");

// ... other properties    }

}

An unhandled error has occurred. Reload πŸ—™