Create a text column with Entity Framework First code

How to create a TEXT field instead of NVARCHAR? Right now i have

public string Text { get; set; } 

But it always becomes an nvarchar column, I need a text column

+7
c # entity-framework
source share
1 answer

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

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

or through the Fluent API:

 modelBuilder.Entity<YourEntityTypeHere>() .Property( e => e.Text) .HasColumnType( "text" ); 
+23
source share

All Articles