ORA-12704 Error with Code First

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
yensid21
Posts: 11
Joined: Fri 17 Sep 2010 16:16

ORA-12704 Error with Code First

Post by yensid21 » Mon 12 Sep 2011 15:06

I am getting an ORA-12704 error using the code-first model. I am using version 6.30.202.0 of your product for Oracle.

Here is the SQL generated by the framework:

SELECT
"Limit1".C2 AS C1,
"Limit1".C1 AS C2,
"Limit1".REFERRED_TO AS REFERRED_TO,
"Limit1".ENTITY_TYPE AS ENTITY_TYPE,
"Limit1".STATUS AS STATUS,
"Limit1".VERSION AS VERSION,
"Limit1".C3 AS C3,
"Limit1".C4 AS C4,
"Limit1".C5 AS C5,
"Limit1".C6 AS C6,
"Limit1".C7 AS C7,
"Limit1".C8 AS C8,
"Limit1".C9 AS C9,
"Limit1".C10 AS C10,
"Limit1".C11 AS C11,
"Limit1".C12 AS C12,
"Limit1".C13 AS C13,
"Limit1".C14 AS C14,
"Limit1".C15 AS C15,
"Limit1".C16 AS C16,
"Limit1".C17 AS C17,
"Limit1".C18 AS C18,
"Limit1".C19 AS C19,
"Limit1".C20 AS C20,
"Limit1".C21 AS C21
FROM ( SELECT
"UnionAll1".ID AS C1,
"Extent3".REFERRED_TO AS REFERRED_TO,
"Extent3".ENTITY_TYPE AS ENTITY_TYPE,
"Extent3".STATUS AS STATUS,
"Extent3".VERSION AS VERSION,
CASE WHEN "UnionAll1".C13 = 1 THEN '0X0X' ELSE '0X1X' END AS C2,
CASE WHEN "UnionAll1".C13 = 1 THEN "UnionAll1".BUSINESS_NAME END AS C3,
CASE WHEN "UnionAll1".C13 = 1 THEN "UnionAll1".EIN END AS C4,
CASE WHEN "UnionAll1".C13 = 1 THEN "UnionAll1".START_DATE END AS C5,
CASE WHEN "UnionAll1".C13 = 1 THEN "UnionAll1".END_DATE END AS C6,
CASE WHEN "UnionAll1".C13 = 1 THEN "UnionAll1".COMMENTS END AS C7,
CASE WHEN "UnionAll1".C13 = 1 THEN "UnionAll1".HOURS_OF_OPERATION END AS C8,
CASE WHEN "UnionAll1".C13 = 1 THEN "UnionAll1".PRIMARY_CONTACT_ID END AS C9,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NCHAR(NULL) ELSE "UnionAll1".C1 END AS C10,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NCHAR(NULL) ELSE "UnionAll1".C2 END AS C11,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NCHAR(NULL) ELSE "UnionAll1".C3 END AS C12,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NCHAR(NULL) ELSE "UnionAll1".C4 END AS C13,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NCHAR(NULL) ELSE "UnionAll1".C5 END AS C14,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NCHAR(NULL) ELSE "UnionAll1".C6 END AS C15,
CASE WHEN "UnionAll1".C13 = 1 THEN CAST(NULL AS TIMESTAMP(9)) ELSE "UnionAll1".C7 END AS C16,
CASE WHEN "UnionAll1".C13 = 1 THEN CAST(NULL AS TIMESTAMP(9)) ELSE "UnionAll1".C8 END AS C17,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NUMBER(NULL) ELSE "UnionAll1".C9 END AS C18,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NCHAR(NULL) ELSE "UnionAll1".C10 END AS C19,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NCHAR(NULL) ELSE "UnionAll1".C11 END AS C20,
CASE WHEN "UnionAll1".C13 = 1 THEN TO_NUMBER(NULL) ELSE "UnionAll1".C12 END AS C21
FROM (SELECT
"Extent1".ID AS ID,
"Extent1".BUSINESS_NAME AS BUSINESS_NAME,
"Extent1".EIN AS EIN,
"Extent1".START_DATE AS START_DATE,
"Extent1".END_DATE AS END_DATE,
"Extent1".COMMENTS AS COMMENTS,
"Extent1".HOURS_OF_OPERATION AS HOURS_OF_OPERATION,
"Extent1".PRIMARY_CONTACT_ID AS PRIMARY_CONTACT_ID,
TO_CHAR(NULL) AS C1,
TO_CHAR(NULL) AS C2,
TO_CHAR(NULL) AS C3,
TO_CHAR(NULL) AS C4,
TO_CHAR(NULL) AS C5,
TO_CHAR(NULL) AS C6,
CAST(NULL AS TIMESTAMP(9)) AS C7,
CAST(NULL AS TIMESTAMP(9)) AS C8,
TO_NUMBER(NULL) AS C9,
TO_CHAR(NULL) AS C10,
TO_CHAR(NULL) AS C11,
TO_NUMBER(NULL) AS C12,
1 AS C13
FROM "A$ENTITY".BUSINESSES "Extent1"
UNION ALL
SELECT
"Extent2".ID AS ID,
TO_CHAR(NULL) AS C1,
TO_CHAR(NULL) AS C2,
CAST(NULL AS TIMESTAMP(9)) AS C3,
CAST(NULL AS TIMESTAMP(9)) AS C4,
TO_CHAR(NULL) AS C5,
TO_CHAR(NULL) AS C6,
TO_NUMBER(NULL) AS C7,
"Extent2".TITLE AS TITLE,
"Extent2".FIRST_NAME AS FIRST_NAME,
"Extent2".MIDDLE_NAME AS MIDDLE_NAME,
"Extent2".LAST_NAME AS LAST_NAME,
"Extent2".SECONDARY_LAST_NAME AS SECONDARY_LAST_NAME,
"Extent2".SUFFIX AS SUFFIX,
"Extent2".DOB AS DOB,
"Extent2".DOD AS DOD,
"Extent2".RACE_TYPE AS RACE_TYPE,
"Extent2".GENDER AS GENDER,
"Extent2".MARITAL_STATUS AS MARITAL_STATUS,
"Extent2".PHYSICAL_CHARACTERISTICS_ID AS PHYSICAL_CHARACTERISTICS_ID,
0 AS C8
FROM "A$ENTITY".PERSONS "Extent2") "UnionAll1"
INNER JOIN "A$ENTITY".LEGAL_ENTITIES "Extent3" ON "UnionAll1".ID = "Extent3".ID
WHERE ("UnionAll1".ID = :p0) AND ROWNUM <= 2
) "Limit1"

And this is the code I am using which is generating the problem:

using (RepositoryContext context = new RepositoryContext(con))
{
var updateValue = context.Persons.Find(value.Id);
var tmpValue = (Person)value;

updateValue.DOB = tmpValue.DOB;
updateValue.DOD = tmpValue.DOD;
updateValue.EntityType = tmpValue.EntityType;
updateValue.FirstName = tmpValue.FirstName;
updateValue.Gender = tmpValue.Gender;
updateValue.LastName = tmpValue.LastName;
updateValue.MaritalStatus = tmpValue.MaritalStatus;
updateValue.MiddleName = tmpValue.MiddleName;
updateValue.Race = tmpValue.Race;
updateValue.ReferredTo = tmpValue.ReferredTo;
updateValue.SecondaryLastName = tmpValue.SecondaryLastName;
updateValue.Status = tmpValue.Status;
updateValue.Suffix = tmpValue.Suffix;
updateValue.Title = tmpValue.Title;
updateValue.Version = tmpValue.Version;

return context.SaveChanges();
}

In the SQL statement generated, I noticed that there are TO_NCHAR statements. When I change those to TO_CHAR, it fixes the problem. I have also found that if I set the IsUnicode value to false using the fluent interface for each string property in the class that also fixes the problem. However, I have some abstract base classes and I haven't figured out how to set the IsUnicode value on them yet.

Thanks.

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 13 Sep 2011 14:10

System.Data.Entity.ModelConfiguration.Conventions.PropertyMaxLengthConvention is responsible for setting IsUnicode=true by default for all string properties in the model. Try turning it off. This should help.

yensid21
Posts: 11
Joined: Fri 17 Sep 2010 16:16

Resolved

Post by yensid21 » Wed 14 Sep 2011 12:19

This fixed the problem. Thanks!

jared
Posts: 10
Joined: Wed 12 Oct 2011 22:12

Post by jared » Fri 14 Oct 2011 22:19

I have the same issue and removing PropertyMaxLengthConvention fixed some of the TO_NCHAR references, but not all of them, I still have instances of queries that fail.

Shalex
Site Admin
Posts: 8248
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 24 Oct 2011 17:12

Please try the latest (6.50.237) build of dotConnect for Oracle. This build includes the fix for the bugs with character set mismatch.

Post Reply