Entity Framework 4.1 - What does RequiredAttribute really mean?
I'm having a database computed field in my Code-First model. I've marked that with the DatabaseGeneratedAttribute. Do I need to specify the RequiredAttribute too?
In other words: Does 'required' mean, that it's req开发者_如何学编程uired this value is assigned to? Or does it mean, that this value is not allowed to be null.
RequiredAttribute
is used for both validation and mapping definition. If you define string
property without this attribute it is defined as nullable column in the database but with this attribute it is not nullabe. In other words it says if property can contain null
both during validation and in the database.
精彩评论