✅ EFCore cannot map another entity
I'm trying to move the relation so that the
DiscordUser
has the UserId
(and not User
the DiscordUserId
)
To do that, I've dropped the entire database since idc about it right now, got rid of all migrations but it keeps saying it can't map the User
User: https://pastebin.com/ARS3JPiD
DiscordUser: https://pastebin.com/mBmUJpP5
DbContext: https://pastebin.com/ybtVHALe
Exception: https://pastebin.com/raw/0j8bsks6
Uncommenting the [InverseProperty]
also changes the exception to: https://pastebin.com/raw/6z7XswhM6 Replies
Try this [ForeignKey(nameof(UserId))]
And move the attribute to the User
Index on user being unique... Is that valid when it can be null?
Same exception
Well yes, it worked while the relation was the other way and for MySQL each NULL is different
Commenting out the
[Index]
does solve its issues actually though
I guess it already knew that the foreign key should be unique? In database it is with the attribute gone <:panda_shrug:790675338367598643>so, you have your own
User
system, and each User
may or may not have an associated Discord account?
represented by a DiscordUser
record?
and each DiscordUser
has its Id
which is the ID value of that account in Discord's systems, as well as a UserId
value that defines which of YOUR users owns that associated account?
is it because you've told EF to index User
instead of UserId
?It's because I've told EF to index it at all
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.