One of the cool features that PostgreSQL has to offer is the support for array data types. This allows you to store an array in a single column without the need to either use a separate table or concatenate the values in a single string.
To use this in Entity Framework through Npgsql you simply need to define a regular .NET array or List<>
property:
The provider will create text[]
columns for the above two properties, and will properly detect changes in them - if you load an array and change one of its elements, calling SaveChanges()
will automatically update the row in the database accordingly.
More information: https://www.npgsql.org/efcore/mapping/array.html