Came across this error today. It had me confused for a few minutes but it was an easy one to resolve and highlights a potential pitfall with copy/paste of entity maps.
I’m mapping data from an external database into my main app’s repository.
The external datasource has a composite key of 3 fields and these fields have names with suffixes of ‘id’ but they’re strings not ints.
My mapping file had something like
.KeyReference(x => x.Mod_id)
.KeyReference(x => x.Year_id)
.KeyReference(x => x.Prog_id);
‘KeyReference’ was the issue. As the fields / properties were strings I had to change them to ‘KeyProperty’.
.KeyProperty(x => x.Mod_id)
.KeyProperty(x => x.Year_id)
.KeyProperty(x => x.Prog_id);