Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do longtext with code first approach

I am trying to generate longtext type database column using an Entity Framework code-first approach. I already used Column(TypeName = "longtext") data annotation but I am getting error

Column, parameter, or variable #3: Cannot find data type LONGTEXT.

My code:

public class MyText
{
    [Key]
    public int Id { get; set; }

    [Column(TypeName = "longtext")]
    public string Txt { get; set; }
}

Any idea how I can generate a longtext column then?

like image 410
Jona Pie Avatar asked Dec 01 '25 02:12

Jona Pie


1 Answers

here you go - pretty straight forward...

public class MyText
{
    [Key]
    public int Id { get; set; }

    //leaving this blank it will give you nvarchar(MAX)
    public string Txt { get; set; }
}
like image 154
Jazb Avatar answered Dec 05 '25 09:12

Jazb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!