Hi, I'm using CodeFirst and the last version of dotConnect.
I see that the string property are mapped as NCLOB / NVARCHAR2.
Is it possible to set the ModelBuilder for use CLOB/VARCHAR2 ?
I try setting the "Unicode" property on the connection string, but this doesn't seem to work.
Thank you in advance
Using VARCHAR2 instead of NVARCHAR2
-
- Devart Team
- Posts: 2420
- Joined: Wed 02 Nov 2011 09:44
Re: Using VARCHAR2 instead of NVARCHAR2
By default, strings in EF Code-First are considered as unicode and without explicit length. That's why it is of the NCLOB type. It would be VARCHAR2 if the [not unicode string] and [length < 4000 symbols] settings were specified in fluent (or attribute) mapping for a property.
Solution for the attribute mapping. If you indeed have the type in your database which differs from NCLOB, specify this explicitly (at least for the columns which take part in CASEs). Edited! E.g.: set the MaxLength(123) attribute if you have the NVARCHAR2(123) column in your database. Also turn off PropertyMaxLengthConvention from the Conventions collection in DbModelBuilder (this convention is used for unicode strings).
Solution for the fluent mapping. Set HasMaxLength(123) and IsUnicode(false) for the corresponding property. In this case there is no need to turn off PropertyMaxLengthConvention.
Solution for the attribute mapping. If you indeed have the type in your database which differs from NCLOB, specify this explicitly (at least for the columns which take part in CASEs). Edited! E.g.: set the MaxLength(123) attribute if you have the NVARCHAR2(123) column in your database. Also turn off PropertyMaxLengthConvention from the Conventions collection in DbModelBuilder (this convention is used for unicode strings).
Solution for the fluent mapping. Set HasMaxLength(123) and IsUnicode(false) for the corresponding property. In this case there is no need to turn off PropertyMaxLengthConvention.
-
- Posts: 54
- Joined: Mon 05 Jul 2010 23:08
Re: Using VARCHAR2 instead of NVARCHAR2
Sorry, but maybe I wasn't clear.
I found this solution (write an annotation for each property), but since ALL my string has to be threat in the same way (unicode = false), there is a place where I can set it once and not for all properties?
I found this solution (write an annotation for each property), but since ALL my string has to be threat in the same way (unicode = false), there is a place where I can set it once and not for all properties?
-
- Devart Team
- Posts: 2420
- Joined: Wed 02 Nov 2011 09:44
Re: Using VARCHAR2 instead of NVARCHAR2
We are planning to implement additional settings for the Entity Framework provider soon, they will allow performing string types mapping customization easily and in one place. But this functionality will not be included in the nearest builds.
-
- Posts: 54
- Joined: Mon 05 Jul 2010 23:08
Re: Using VARCHAR2 instead of NVARCHAR2
Thank you a lot.
For now we will set the configuration for each property
For now we will set the configuration for each property
Re: Using VARCHAR2 instead of NVARCHAR2
New version of dotConnect for Oracle 7.1 is released!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=1&t=24522 .
This version includes the config.CodeFirstOptions.UseNonUnicodeStrings configuration option (default value is False) to treat string properties without an explicitly specified server data type as non-unicode.
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=1&t=24522 .
This version includes the config.CodeFirstOptions.UseNonUnicodeStrings configuration option (default value is False) to treat string properties without an explicitly specified server data type as non-unicode.
-
- Posts: 54
- Joined: Mon 05 Jul 2010 23:08
Re: Using VARCHAR2 instead of NVARCHAR2
Thank you a lot!