Intellenum icon indicating copy to clipboard operation
Intellenum copied to clipboard

EF Core compatibility

Open arteny opened this issue 9 months ago • 1 comments

Describe the bug

Using Visual Studio EF Core, I am adding Intellenum column property (ChannelId type). Then if I am adding migration (with code-first approach), I get the error: Unable to create a 'DbContext' of type 'MyDb'. The exception 'The entity type 'ChannelId' 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 Looks like it is going to create separate table for this type values, when I expect just column type with type int. So when it is working for Vogen value objects, for Intellenum it is not. Is it possible to add such EF Core compatibility?

Steps to reproduce

  1. Add Intellenum property to db entity class.
  2. Run add-migration

Expected behaviour

No error, Intellenum property is mapped as it's underlying type for column type.

arteny avatar Mar 14 '25 13:03 arteny

Howerver I found that using EnumGenerators instead of Intellenum is good enough for my purposes for int values.

arteny avatar Mar 14 '25 16:03 arteny