开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜