You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
[ValueObject(typeof(string), conversions: Conversions.EfCoreValueConverter)]
public partial class EventId
{..
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:
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
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
The text was updated successfully, but these errors were encountered: