开发者

Entity Framework 4.1 Want the Model to have non-null validatiom but dont want the database to be not null

开发者 https://www.devze.com 2023-03-21 16:01 出处:网络
This might sound l开发者_JS百科ike a weird request but how do I enforce validation at the model level using DataAnnotations that aren\'t enforced at the data store level when using EF 4.1 Code First.Y

This might sound l开发者_JS百科ike a weird request but how do I enforce validation at the model level using DataAnnotations that aren't enforced at the data store level when using EF 4.1 Code First.


You cannot do that if you want to generate database from your mapping. Data annotation on mapped class defines mapping to database. If you need somewhere in UI to enforce different rules you need separate class for that - for example View model in ASP.NET MVC.

0

精彩评论

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