I’m running into an issue when trying to save related entities through a junction table setup using Umbraco UIBuilder v16.0.1. I’m hoping someone can shed some light on this.
Context:
I’m working with the following entity setup:
Currency (main entity)
Country (related entity)
CountryCurrency (junction entity with a composite key: {CurrencyId, CountryId})
In UIBuilder, I’m adding a related collection field like this:
.AddRelatedCollectionPickerField<CountryCurrency>("countryCurrencies", "Countries Related Picker", "Select a country for this currency");
This works perfectly for displaying the related data, but I’m unable to save new related entries properly.
The Problem:
When saving, I get the following exception:
System.FormatException: The input string ‘ef93b989-de18-4899-b3cf-08ddbd225b65’ was not in a correct format.
It is trying to parse the Guid key to an integer in the updatecontroller. Is it not possible to use Guids as keys when working with related collections?
This is the line it crashes on, because of the parse
object entity2 = entityController.EntityService.NewRelationEntity(relationPropertyConfig, propertyValue, (object) int.Parse(s, NumberStyles.Integer, (IFormatProvider) CultureInfo.InvariantCulture));