Use string primary in Neos
The use of string primary keys is specific. It is recommended to use auto-incremented primary keys. But, if you are using an existing database containing tables with string primary keys, then here's how to proceed.
Configure the entity
The primary key is a string property that should be required without a default value.
You can set the primary key value in Saving rule.
Example:
public async Task OnSavingAsync(ISavingRuleArguments<EntityBaseWithStringPK> args)
{
foreach(var item in args.CreatedItems)
{
item.Id = "ABCDE" + System.Guid.NewGuid().ToString("N");
}
}
Configure the entiy view
On the entity view, configures the primary key as not required. This means that when it is created, the key is not mandatory because it is initialized by the entity.
Configure the UI view
On the UI view, configures the primary has not required.
That's all there is to it. Now the backend and frontend are ready.