Marcar propiedad como clave en POCO

I have a POCO object and I want to mark a property as a key (see TestClass below). I'm getting the following error.

'Key' cannot be used as an attribute because it is not a class. C:\Users\zzz\Documents\Visual Studio 2010\Projects\zzz\zzz\BO\TestClass.vb

Public Class TestClass

  <Key()>
  Private _TestIdentifier As String
  Public Property TestIdentifier() As String
    Get
        Return _TestIdentifier
    End Get
    Set(ByVal value As String)
      _TestIdentifier = value
      '  Me.NotifyPropertyChanged("TestIdentifier")
    End Set
  End Property

End Class

preguntado el 09 de marzo de 12 a las 16:03

The error speaks for itself, Key() isn't an attribute. Why do you need this attribute? I think you should apply it on the property and not in the private value. -

1 Respuestas

I had a missing import and reference Imports System.ComponentModel.DataAnnotations And reference System.ComponentModel.DataAnnotations.dll

respondido 10 mar '12, 01:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.