Entity Framework Error: Unable to track an entity of type OrderItem because primary key property ProductVariant is null

Last Reply 4 months ago By jon

Posted 4 months ago

hi

in my OrderItems table i need a composite key as

Id, ProductCode,ProductVariant

I tested insert in sqlite with null ProductVariant but from webapi post

i recive error

InvalidOperationException: Unable to track an entity of type 'OrderItem' because primary key property 'ProductVariant' is null.

Microsoft.EntityFrameworkCore.ChangeTracking.Internal.NullableKeyIdentityMap<TKey>.Add(InternalEntityEntry entry)

 

How can solve?

This question does not have replies that have been liked.