❔ Entity Framework not required foreign key as required?
I'm currently using ASP.Net Identity as my user scaffold.
My user currently looks like
I've added UserGenre and Genre like this.
5 Replies
To clarify, the database is indeed linked with foreign key constraint.
However, what puzzles me is why
UserId in the table is placed as nullable, however, Genre is not nullable.
I wanted both to be non nullable but it doesn't seem to work in my way that i intended?
I could force it to be [Required] which should fulfil my requirement but is that okay?
Using
[Required]
is okay 👍Okay thanks! i'll stick with
[Required]
just weird that null!; works on Genre but not UserWould that be due to
GenreId
being an int
and therefore can not be null and not the = null!
, where as UserId
is a string which can be null?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.