I typically work with my DBA to design my database tables before I begin developing. In nearly all instances, I use the varchar datatype for storing strings in my SQL database.
When I use EF Power Tools to generate my model classes, the column names and lengths get generated correctly, but I always have to go back in and specify HasColumnType("varchar");
because by default everything is nvarchar (I know this by looking at the queries EF generates and the sitautions where it needs to CAST() to varchar).
Is there any way I can generate my model classes from my database and have EF know the correct data types (varchar vs nvarchar)? Meaning, is there anyway I can auto generate my C# model class for my varchar(50) column to show as:
this.Property(t => t.MyColumn)
.HasMaxLength(50)
.HasColumnType("varchar");
Thank you.