3

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")]
    public string Name { get; set; }
} 

The compiler says "Name is already defined".

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Rob
  • 1,297
  • 2
  • 16
  • 30

1 Answers1

3

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

Community
  • 1
  • 1
Kendrick
  • 750
  • 5
  • 10