10 Replies
and the
UserEntity
:
what am i doing wrong?
exception:
i also tried using .HasColumnName, but it didn't helpwhy in the world is
Username
its own class?
or struct?
u.Username.Value
is invalid
Username
is not an entity type you've registered with EF, so it doesn't know how to navigate .Value
and the value conversion you've defined doesn't help
all that does is tell EF to store that column as a string
, and how to convert the two back and forth as yhey go to and from the databasesmells of DDD
what's up with this? @demndev
you're trying to be wayyyyyy too clever with your entities
some cleverness is fine, like in my Discord bots I have a value converter for Snowflake that converts it to/from ulong
but generally your database entities should just be data
no cleverness
it's a value object
yes, it's something like DDD
you can set up a value converter
but then you need to use
Username
opaquely
i.e. just do someUsername == anotherUsername
not someUsername.Value == anotherUsername.Value
okay…
what is a value converter and how can i set up it?
it's the HasConversion stuff you're already doing
so if the drop the
.Value
stuff, it should all workthanks!
remember, EF isn't actually running the expressions you give it
it's translating them to SQL
so it's looking for a column to act on
and your Username column doesn't have a Value property in the database
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.