Duplicate mapping to column 'CustomerID' in class 'xCustomers'

639 views Asked by At

I get the error Duplicate mapping to column 'CustomerID' in class 'xCustomers' in the following class, but i do not know what am i doing terribly wrong.

Public Class xCustomers
    Inherits XPBaseObject

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub

    <Key(True), Persistent("CustomerID")> Private _CustomerID As Integer = -1
    Public Property CustomerID() As Integer
        Get
            Return _CustomerID
        End Get
        Set(ByVal value As Integer)
            SetPropertyValue(Of Integer)("CustomerID", _CustomerID, value)
        End Set
    End Property

End Class

And here is the C# version

public class xCustomers : XPBaseObject
{

    public xCustomers(Session session) : base(session)
    {
    }

    [Key(true), Persistent("CustomerID")]
    private int _CustomerID = -1;
    public int CustomerID {
        get { return _CustomerID; }
        set { SetPropertyValue<int>("CustomerID", _CustomerID, value); }
    }

}

Any ideas please?

1

There are 1 answers

0
Will Wu On BEST ANSWER

you should add the Attribute [Key(true), Persistent("CustomerID")] before public int CustomerID, not private int _CustomerID.