Entity Framework Core jsonb column type

c# entity-framework-core npgsql postgresql

Question

I am using Entity Framework Core with npgsql postgresql for Entity Framework Core.

My question is, using migrations, how do I mark a class property to generate a JSONB column type?

For example:

public class MyTableClass
{
    public int Id { get; set; }

    // My JSONB column
    public string Data { get; set; }
}

Thanks in advance.

1
13
4/4/2017 4:02:05 PM

Accepted Answer

Based on H. Herzl comment:

My final solution was something like this:

public class MyTableClass
{
    public int Id { get; set; }

    [Column(TypeName = "jsonb")]
    public string Data { get; set; }
}

Migrations generated this:

Data = table.Column<string>(type: "jsonb", nullable: true),

When updated the database with migrations, the Data column was created correctly with jsonb type.

Thank you H. Herzl!

18
11/29/2017 10:23:36 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow