create text column with Entity Framework Code First

.net, c#, entity-framework

Solution

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" );

Problem

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

Original source

Related problems