Reputation: 1153
I am using code-first migrations in EF6, and I need to change the default database type for string parameters in my DB from nvarchar to varchar for just one table/entity.
I have found how to do this globally by entering the following into my model building in my context class.
modelBuilder.Properties<string>().Configure(c => c.HasColumnType("varchar"));
But this is not what I want, I only want it to affect my dbo.Contacts table.
Is there a way of only applying this only to one entity? I'd want to do it with model builder as I am using automatic migrations, and prefer to have my migrations built from the model build configurations.
Upvotes: 0
Views: 920
Reputation: 126
You can use DataAnnotations like:
[Column(“BlogDescription", TypeName="ntext")]
Or can try use Mappings with Fluent API.
see more: http://www.entityframeworktutorial.net/code-first/configure-property-mappings-using-fluent-api.aspx
Upvotes: 1