Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create text column with Entity Framework Code First [duplicate]

How can I create a field that is TEXT instead of NVARCHAR? Right now I've got

public string Text { get; set; }

But that always becomes a nvarchar column, I need a Text column

like image 935
user3052560 Avatar asked Dec 02 '13 18:12

user3052560


1 Answers

You can use System.ComponentModel.DataAnnotations.Schema.ColumnAttribute

[Column(TypeName = "text")]
public string Text { get; set; }

or via Fluent API:

modelBuilder.Entity<YourEntityTypeHere>()
    .Property( e => e.Text)
    .HasColumnType( "text" );
like image 59
Moho Avatar answered Sep 20 '22 14:09

Moho