Entity Framework 4.1 - What Does RequiredAttribute Really Mean?

I have a field for calculating a database in my Code-First model. I noted this with DatabaseGeneratedAttribute. Should RequiredAttribute also be specified?

In other words: โ€œRequiredโ€ means that this requires an assignment of this value? Or it means that this value is not allowed to be null.

+4
source share
1 answer

RequiredAttribute used both for validation and for mapping determination. If you define a string property without this attribute, it is defined as a null column in the database, but with this attribute it does not have a nullabe value. In other words, he says that if a property can contain null both during validation and in the database.

+2
source

All Articles