create text column with Entity Framework Code First

.net c# entity-framework

Question

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

1
9
12/2/2013 6:45:08 PM

Accepted Answer

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" );
33
6/28/2014 2:31:50 PM


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