开发者

ADO.NET Entities - Model-first data annotations

I'm using the approach explained here:-

http://blogs.msdn.com/b/adonet/archive/2010/12/06/ef-feature-ctp5-code-first-walkthrough.aspx

I'd like to use the surface designer to develop my model, then use partial classes to include data annotations for validation. However, if I use a partial class and then attempt to reference an existing property the compiler complains that the property already exists.

How do I get over this?


e.g.

public partial class Product
{
    [Required(ErrorMessage="Name is required")]
    pu开发者_高级运维blic string Name { get; set; }
} 

The compiler says "Name is already defined".


I just ran across the same problem on how to annotate an entity class that is generated from the Entity Data Model and I found the answer on another stackoverflow thread:

Using System.ComponentModel.DataAnnotations with Entity Framework 4.0

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜