Error: the entity type requires a primary key

后端 未结 11 1654
走了就别回头了
走了就别回头了 2020-12-02 15:30

I would like to expand the question asked on this thread

Binding listbox to observablecollection

by giving it an ability to persistent the data. The structur

11条回答
  •  时光说笑
    2020-12-02 15:55

    The entity type 'DisplayFormatAttribute' requires a primary key to be defined.

    In my case I figured out the problem was that I used properties like this:

    public string LastName { get; set; }  //OK
    public string Address { get; set; }   //OK 
    public string State { get; set; }     //OK
    public int? Zip { get; set; }         //OK
    public EmailAddressAttribute Email { get; set; } // NOT OK
    public PhoneAttribute PhoneNumber { get; set; }  // NOT OK
    

    Not sure if there is a better way to solve it but I changed the Email and PhoneNumber attribute to a string. Problem solved.

提交回复
热议问题