Is there any way to use ARRAY in Entity Framework + PostgreSql

Can arrays be used in Entity Framework with PostgreSql?

Suppose, for example, that we had a POCO class

        public class MyTable
        {
            [Key]
            [Column("gid")]
            public int Gid { get; set; }
            [Column("name")]
            public string Name { get; set; }
            [Column("email")]
            public string Email { get; set; }
            [Column("somedata")]
            public int[] SomeData { get; set; }
        }

At this point, the Entity Framework simply does not create the "somedata" column and skips it. Is there any way to do this anyway? And I mean that you do not need to use a separate table. Postgres arrays come in handy from time to time when you want to keep a small or limited number of values ​​in one column.

+4
source share
1 answer

, Entity Framework Core Npgsql EF Core.

:

[Column("somedata", TypeName = "integer[]")]
public int[] SomeData { get; set; }
+2

All Articles