The property on entity type is part of a key and so cannot be modified or marked as modified
I solved the problem thanks to Rowan Miller. He said:
In EF Core, an alternate key is designed to be used as the target of a relationship (i.e. there will be a foreign key that points to it). Currently EF does not support changing the values.
If I want a unique index on the property, then I must use this code:
modelBuilder.Entity<UnitGroup>().HasIndex(u => u.Name).IsUnique();