EF Code First varchar (emit .IsUnicode(false))

Posts   
 
    
dle4425
User
Posts: 7
Joined: 04-Jan-2017
# Posted on: 06-Jan-2017 16:16:31   

Is there a way have .IsUnicode(false) added to string fields when the EF code first code is generated?

I have unchecked Project Settings/Model First Development/Prefer natural character types but it doesn't seem to make any difference.

For background I am trying to use LLBLGen to model an existing database and generate the code first files. I would like to be able to use migrations and generate a test database for integration testing. So even though the runtime doesn't need this migrations do. Without it migrations are altering all of the varchar columns to make them nvarchar. Something I'd rather not have to do at this point.

I think I could probably alter the template to do this but I'd like to do it the right way. Is there a way to get the "Prefer natural character types" settings from a template?

Thanks,

Dave Erwin

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Jan-2017 05:39:33   

Hi Dave,

According to docs...

Prefer natural character types When set to true (default), the designer will, when creating a relational model data field element, prefer natural character database types (e.g. nvarchar, nchar) over normal character database types (e.g. char, varchar), when more than one database type matches the model element's .NET type. When set to false, normal character database types are prefered.

... this setting is for Relational model data element construction, not for generated .net code.

However, this is something you could implement on your own, using custom framework settings and creating your own custom template that overrides the built-in one. (More info on SDK Docs).

David Elizondo | LLBLGen Support Team