❔ EF Core setting property with value converter to null
i have a value object
that i'm mapping to a column in EF core with
.
my problem is that while writing to the database works fine, any operation that tries to read this column back without directly selecting it either sets it to null or just doesn't initialize it in the first place. selecting the column specifically like
dbContext.ShippingOrders.Where(x => x.Number == new ShippingOrderNumber(1)).Select(x => x.Number).First()
works. but something like db.ShippingOrders.AsNoTracking().OrderByDescending(x => x.Number).FirstOrDefault()
or simply dbContext.ShippingOrders.First().Number
returns null or blows up the change tracker because it thinks the entity's key is null. i have no idea what's going on at this point, i have two other entities with practically copy/pasted variants of this setup and they work fine.
in all cases the value objects are non-null primary keys and they definitely have values in the database.2 Replies
i'm not sure where to debug it from because when it calls the constructor for the object it's always an expected value, so somewhere it's just not instantiating anything
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.