Closed arteny closed 7 months ago
OK, I found finally how to make it working. For structs I also need to specify conversions parameter
[ValueObject<string>(conversions: Conversions.EfCoreValueConverter)]
and add mapping for this property
This goes against the documentation, which states that for structs there's nothing to do.
I think the documentation might be incorrect. Whether a struct or class, EFCore still needs help in creating it.
I created PR #569
Describe the bug
In main readme doc it is written that using structs no needs additional actions and works as is, but not working on my side with following error message:
Unable to create a 'DbContext' of type ''. The exception 'The property 'Market.Id' could not be mapped because it is of type 'MarketId', which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
full doc for EFCore https://stevedunn.github.io/Vogen/value-objects-in-efcore.html is not available if i switch it to class and using this type:
then another error is returned:
Unable to create a 'DbContext' of type ''. The exception 'The entity type 'Event' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'. For more information on keyless entity types, see https://go.microsoft.com/fwlink/?linkid=2141943.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
when key is defined:Steps to reproduce
add-migration
Expected behaviour
No error