Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EFCore 8.1 not supported #557

Closed
arteny opened this issue Jan 31, 2024 · 4 comments
Closed

EFCore 8.1 not supported #557

arteny opened this issue Jan 31, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@arteny
Copy link

arteny commented Jan 31, 2024

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:

[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:

	public class Event
	{
		[Key]
		public required EventId Id { get; set; }

Steps to reproduce

add-migration

Expected behaviour

No error

@arteny arteny added the bug Something isn't working label Jan 31, 2024
@arteny
Copy link
Author

arteny commented Feb 1, 2024

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

@arteny arteny closed this as completed Feb 1, 2024
@ronnieoverby
Copy link
Contributor

This goes against the documentation, which states that for structs there's nothing to do.

@SteveDunn
Copy link
Owner

I think the documentation might be incorrect. Whether a struct or class, EFCore still needs help in creating it.

@ronnieoverby
Copy link
Contributor

I created PR #569

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants