15

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

user3052560
  • 177
  • 1
  • 1
  • 7
  • There are a lot of different ways to do this. What is your current approach for configuration of column store types? Are you using ModelBuilder? EF Migrations? Attributes? – mwilson Dec 02 '13 at 18:47
  • I'm just starting out with c# and .net. I know how to use EF migrations yea. Isn't there any kind of annotation that I can put on the attribute that makes it a TEXT column? – user3052560 Dec 02 '13 at 18:48
  • See here: http://stackoverflow.com/a/4913615/328123 Edit: or Moho's answer :) – mwilson Dec 02 '13 at 18:54

1 Answers1

43

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" );
Bakudan
  • 19,134
  • 9
  • 53
  • 73
Moho
  • 15,457
  • 1
  • 30
  • 31