Since EFCore, the IsOptional
-Method was removed from the FluentAPI. I've found this question here Required property but Nullable, Entity Framework through Code First, where using IsOptional
was a solution for this issue.
What to do now? I'd like to use my EFCore models for both validation and storage but the rules do differ (e.g. Email is allowed to be null in the Database, but not for the validation).
The answer is quite simple: IsRequired(false)
- there is an overload that replaces IsOptional()
.
Thank to @roji @Github
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments