EF core list of string datatype to postgresql

Viewed 1841

I am using EF core 1.1.1 & postgresql with code-first implementation.

I have a model class with member variable for List as follow.

public class user : IdentityUser
{
    public int id { get; set; }
    [Column("devices", TypeName = "text[]")]
    public List<string> devices { get; set; };
}

I declared datatype as text[] and it shows as text array in database. Saving to database as follow works.

var device = "phone";
user.devices.Add(device);

It stores data in database but it returns an error when I try to call query like this.

if (user.Any(x => x.devices.Count > 0))

Showing error like this.

Can't cast database type _text to List`1'

How can I convert stored text data to List?

Thanks.

1 Answers
Related