andrewlock / StronglyTypedId

A Rosyln-powered generator for strongly-typed IDs
MIT License
1.52k stars 79 forks source link

EF Core 3.1 doesn't autogenerate IDs #25

Closed webseb closed 3 years ago

webseb commented 3 years ago

If I use a Guid based strongly typed id EF Core throws the following exception

System.InvalidOperationException : The property 'Foo.Id' could not be mapped, because it is of type 'FooId' 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'.

I can work around that issue by initializing the property

public class Foo
{
    public FooId Id { get; set; } = FooId.New();
}

but auto-generation by convention would be really nice.

Is that possible?

webseb commented 3 years ago

My bad, I butchered your sample code and forgot to add the nested StronglyTypedIdEfValueConverter