'Entity Framework Core - the property 'Post.Videos' is of type 'List<string>' which is not supported by the current database provider

I am working on an ASP.NET Core project. I am trying to add jsonb column to my table.

I got this error

The property 'Post.Videos' is of type 'List' which is not supported by the current database provider. Either change the property CLR type, or ignore the property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

post.cs

public List<string> Images { get; set; }    // jsonb
public List<string> Videos { get; set; } // jsonb

PostConfiguration.cs

builder.Property(i => i.Images)
            .HasColumnType("jsonb");

builder.Property(i => i.Videos)
            .HasColumnType("jsonb");

Why does this error occur? What is wrong with my configurations?



Solution 1:[1]

Entity Framework does not support list of string. You can create an other entity or convert your stringlist to string

public class SomeObj
    {
        public SomeObj()
        {
            this.Pics = new List<Pic>();
        }
        public int Id { get; set; }
        public List<Pic> Pics { get; set; }        
    }
    public class Pic
    {
        public int Id { get; set; }
        public string Picstring { get; set; }

        public int SomeObjId { get; set; }
        public SomeObj SomeObj{ get; set; }
    }
    public class Video
    {
        public int Id { get; set; }
        public string Picstring { get; set; }
        public int SomeObjId { get; set; }
        public SomeObj SomeObj { get; set; }
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1