3

I want to override the default nvarchar(4000) for one of my string columns to a text data type in SQL Express. I use this code.

modelBuilder.Entity<Accommodation>()
               .Property(p => p.Information)
               .HasColumnType("text");

But the column type remains as nvarchar?

I also asked here http://social.msdn.microsoft.com/Forums/en/adonetefx/thread/a1d84ea9-2f8e-42f0-bb83-ac9f68805d6d?prof=required

skaffman
  • 398,947
  • 96
  • 818
  • 769
Daveo
  • 19,018
  • 10
  • 48
  • 71
  • 2
    You should consider using _nvarchar(max)_ instead of _text_. Microsoft is keeping the text datatype in SQL Server 2005 and 2008 for backwards compatibility, but they encourage you to use the new nvarchar(max) datatype. (http://msdn.microsoft.com/en-us/library/ms178158(v=SQL.100).aspx) – Kristof Claes Jan 27 '11 at 11:40
  • Excellent point I have changed my code to HasColumnType("varchar(max)"); and it works fine. Thank you – Daveo Jan 27 '11 at 11:47

1 Answers1

1

Ahh I just figured it out, adding the fluent mapping was not sufficient to force the table to dropAndCreate itself again even though I had DropCreateDatabaseIfModelChanges set.

I had to force it to update the table manually.

Daveo
  • 19,018
  • 10
  • 48
  • 71