EF attributes vs built-in C# keywords (like required). Differences and when to use?
Essentially what the title says. In this code
I'm not sure whether I need to add a [Required] tag to the Id or if [Key] makes that redundant, or if I need to make Id required with the c# keyword. I've researched this and what I've found is that the required keyword is checked at compile time while the attributes from EF are checked during runtime and they're what's being used for validation etc.
The obvious question I have is to always use required attribute where I use the keyword in c#, or vice versa?
Another example here is that my Role will always be defined. I have the [Required] attribute for validation. But do I need to add the required modifier as well?
I'm not sure whether I need to add a [Required] tag to the Id or if [Key] makes that redundant, or if I need to make Id required with the c# keyword. I've researched this and what I've found is that the required keyword is checked at compile time while the attributes from EF are checked during runtime and they're what's being used for validation etc.
The obvious question I have is to always use required attribute where I use the keyword in c#, or vice versa?
Another example here is that my Role will always be defined. I have the [Required] attribute for validation. But do I need to add the required modifier as well?
